-
1. Re: including CSS and other html elements - context problem
matt.drees Oct 6, 2007 4:47 PM (in response to yacho)I do this:
<c:set value="#{facesContext.externalContext.requestContextPath}" var="rootPath"/> <link href="#{rootPath}/stylesheet/theme.css" rel="stylesheet" type="text/css" /> <link href="#{rootPath}/stylesheet/layout.css" rel="stylesheet" type="text/css" />
It may make more sense to put a<factory name="rootPath" value="{facesContext.externalContext.requestContextPath} scope="stateless"/>
in components.xml (instead of the c:set) if you'll be using that in a lot of places. -
2. Re: including CSS and other html elements - context problem
yacho Oct 6, 2007 5:19 PM (in response to yacho)thank you so much.' Is there any documentation wich describes what i can or cannot do in components.xml (i dont quite get if it belongs to JSF) please point me to some reference so i wont ask more questions regarding simmilar stuff ;)
-
3. Re: including CSS and other html elements - context problem
matt.drees Oct 7, 2007 12:30 AM (in response to yacho)http://docs.jboss.com/seam/2.0.0.CR1/reference/en/html/
It's a Seam-specific thing. -
4. Re: including CSS and other html elements - context problem
onyii5119 Oct 7, 2007 10:41 AM (in response to yacho)The way I handle it is to define an application path variable in a session scoped class as follows:
private String theAppPath;
then write the getter method for it:
public String getTheAppPath(){
request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
theAppPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+contextPath;
return theAppPath;
}
Then use value binding in my jsf facelet page as follows:
#{beanName.theAppPath}/css/cssFileName.css -
5. Re: including CSS and other html elements - context problem
xshuang Oct 17, 2007 11:19 AM (in response to yacho)Thanks a lot for this message. Just a little more comment, the correct format is
And you cannot add #{rootPath} to ui:composition. It needs to be something like
template="../layout/template.xhtml" >
Or else, it gave error "page not available" but no exception is thrown.