Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem while using CSS with Facelets...  RSS feed

 
Arun Thulaseedharan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new to facelets and in the application im doin now i hav to use css aloing with facelets....when i include css as a separate file and use <link> element in the xhtml page its showing....

May 16, 2008 6:30:10 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
com.sun.facelets.FaceletException: Error Parsing /style.css: Error Traced[line: 2] Content is not allowed in prolog.
at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:234)

but when im hardcoding the styling inside the xhtml file its working fine....Can anyone help me wit this one??

thanks in advance...
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the top few lines of one of my xhtml layout pages:
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah, The "tomahawk" xml namespace declaration is because this page defines an apache myfaces tomahawk menu control (jscookmenu). You don't need it unless you're defining a template with tomahawk controls in it.
 
Arun Thulaseedharan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply...actually the problem was with the
<link> tag ...in the href attribute we cant spedicy the relative ural like we normally do...we hav to make use of this....

<link href="#{facesContext.externalContext.requestContextPath}/style.css" rel="styleSheet" type="text/css"/>
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try a URL of "/style.css" and see what it resolves to. You might need to add an HTML <base> tag to get the context root set properly.

I think Struts has a struts-specific base tag, but I've never actually seen anything on a JSF-specific equivalent. I should look into that.

At worst, since you're using facelets, you can manually define the base in a single easy-to-manage place and reference it using Facelets constructs. Or do a custom Facelets display tag. They're not that hard, though the docs I used to build mine with were confusing - I did a Google Maps tag which has been very useful to me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!