Difficulty with CSS in a JSF2 project

Asked

Viewed 368 times

1

Greeting to all,

I’m new as a Java programmer with JSF projects, I want to put an image as the page plan, and I don’t know how to do.

This is the structure of my project;

inserir a descrição da imagem aqui

I tried to put the line of code in the css file like this;

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

OBS: The structure of Maven.

But it didn’t work.

I need help!

FOR MORE INFORMATION MY PROJECT IS ON GITHUB

https://github.com/wladyband/GestaoADM/tree/master/GestaoADM/src/main/webapp/WEB-INF/template

  • Have you tried this?: background-image:url(".. /.. /Resources/images/papel_de_parede.jpg");

  • that line of code didn’t pick up.

  • Both the folders css how much images are in resources, right? Have you tried something like background-image:url("../images/papel_de_parede.jpg");

4 answers

1

You can do it this way:

On your page .xhtml apply that property

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

Inside this attribute you can assign a class="" or a id="" to manipulate via .css

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

 <link rel="stylesheet" href="#{facesContext.externalContext.requestContextPath}/pasta onde fica o css da ágina" />
  • but the image is inside the images folder, it is not inside the css folder

  • Changes the /css to the folder containing the images.. I put /ccs based on your example

  • Did @wladyband?

  • It didn’t, but I put my project address in the Github repository for you to take a look at,

1

Create a folder structure like this one inside your Webcontent

Crie em

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

I suggest you read up on EL, it might clear up any doubts you didn’t even know you had yet.

1

Try this:

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

1

As you are added CSS by JSF it will manage such CSS. Therefore, to add an image you should use the JSF Expression Language (EL).

For example:

css style.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.