1

how to set background image in jsf.i want to set (imag.jpg)as background. the images

are placed at resouces/images/imag.jpg

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:f="http://java.sun.com/jsf/core"        
      xmlns:h="http://java.sun.com/jsf/html">  

    <h:head>  
        <title>JSF Example</title>                  
        <style>               
        .Bimage{background-image:url("resources/images/imag.jpg"); }        
        </style>   

    </h:head>  
    <h:body styleClass="Bimage">  

    <h:graphicImage library="images" name="download.jpg"> </h:graphicImage>    

     <h3>JSF 2 Example</h3>  
     <h:form>

        <h:inputText value="#{hello.name}"></h:inputText>  

     </h:form>  

    </h:body>  
</html>  
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user3581265
  • 41
  • 1
  • 2
  • 4
  • appropriate answer: http://stackoverflow.com/a/2033828/2459449 – Omar Jun 02 '14 at 09:30
  • thanks for tour reply..i changed like this but not getting – user3581265 Jun 02 '14 at 10:28
  • `resource` without `s`. And depending on what you have inside – Omar Jun 02 '14 at 10:40
  • chaged like that also but not getting – user3581265 Jun 02 '14 at 11:23
  • The image name is "image1" or "imag" ? – Omar Jun 02 '14 at 13:47

1 Answers1

4

Change the css .Bimage by the following code

.Bimage{
     background-image:url(#{request.contextPath}/resources/images/imag.jpg);
 }

or

.Bimage{
     background-image:url(/Project_Name/resources/images/imag.jpg);
 }
Arun Punnath
  • 121
  • 5