Difficulty with CSS in a JSF2 project

1

Greeting for all,

I'm new as a Java programmer with JSF projects, I want to put an image as the page plane, and I do not know how to do it.

This is the structure of my project;

Itriedtoputthelineofcodeinthecssfilelikethis;

background-image:url("/resources/images/papel_de_parede.jpg");

NOTE: The Maven structure.

But it did not work.

I need help!

FOR MORE INFORMATION MY PROJECT IS AT GITHUB

link

    
asked by anonymous 08.07.2015 / 19:33

4 answers

1

You can do this as follows:

On your .xhtml page, apply this property

  <img src="#{facesContext.externalContext.requestContextPath}/images/papel_de_parede.png" alt="" />

Within this attribute you can assign a class="" or a id="" to handle via .css

Remembering that to assign .css to your page you need this:

 <link rel="stylesheet" href="#{facesContext.externalContext.requestContextPath}/pasta onde fica o css da ágina" />
    
08.07.2015 / 19:43
1

As you are adding CSS through JSF it will manage such CSS. So, in order to add image you should use JSF Expression Language (EL).

For example:

style.css

body {
    background-image: url("#{resource['imagens/papel_de_parede.jpg']}");
}
    
09.07.2015 / 15:57
1

Create a folder structure of this type from within your WebContent

After that, you use Expression Language to do what your colleague did above.

I suggest to read about EL, it may leave you with doubts that you did not even know you had.

    
12.08.2015 / 21:32
1

Try this:

<h:body 
    style="background-image:url(#{request.contextPath}/resources/images/textura.jpg);" >
    
12.08.2015 / 22:52