my dog learned polymorphism*
The moose likes JSF and the fly likes Facelets + CSS problem; CSS is not applied after first request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Facelets + CSS problem; CSS is not applied after first request " Watch "Facelets + CSS problem; CSS is not applied after first request " New topic
Author

Facelets + CSS problem; CSS is not applied after first request

Paul Speijers
Greenhorn

Joined: Apr 10, 2005
Posts: 8
In every page of my webapplication I'm using facelets layout page which includes a stylesheet. In order to include the stylesheet I've tried the following options:

Determining the absolute path using a JSF expression:
<link rel="stylesheet" type="text/css" href="#{facesContext.externalContext.request.contextPath}/theme/stylesheet.css" />

And by using the tomahawk stylesheet tag:
<t:stylesheet path="/theme/stylesheet.css" />

I'm using an index.jsp page which forwards to the first page of my webapplication using:
<jsp:forward page="shop/selectbicycle.jsf" />

However, I encounter the following problem:
When I access the index.jsp page it forwards to the selectbicycle.xhtml page and I see my page with the right layout. In other words, the CSS gets applied.
However, after the next requests to other facelets pages (*.jsf gets mapped to *.xhtml), the CSS is not applied to the pages.

Can anyone help me with this? Thanks a lot.

By the way, my layout page looks as follow:


[ April 19, 2007: Message edited by: Paul Speijers ]
Fabio Lin
Greenhorn

Joined: Oct 21, 2005
Posts: 12
Check the generated source code to see if the css path is correct.
Paul Speijers
Greenhorn

Joined: Apr 10, 2005
Posts: 8
That's a good point which I forgot to mention, the generated CSS is correct.

<link rel="stylesheet" type="text/css" href="/BuyABike/theme/stylesheet.css" />

The weird thing is that the generated CSS is the same in the cases where the CSS is applied and when it isn't
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Facelets + CSS problem; CSS is not applied after first request
 
Similar Threads
Problem while using CSS with Facelets...
Help Needed For JSF FACELET RENDERING PROBLEM
Facelets and JSF
JSF, Facelets losing context after reload
Error:The XML page cannot be displayed Cannot view XML input using style sheet