开发者

JSF Cascading Style Sheet not applied when page redirected via listener

I have the follwing listener used via f:event type="preRenderView" listener="#{sessionCheck.loginVerify}"/ in my jsf page:

public void loginVerify() {
  try {
    ExternalContext    eCTX    = FacesContext.getCurrentInstance().getExt开发者_运维百科ernalContext() ;
    HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

    // eCTX.redirect(eCTX.getRequestContextPath() + "/index.xhtml");
    eCTX.dispatch("/index.xhtml");
  } catch (java.lang.Exception e) {}
}

However when I use redirect or disptach the style sheet is not applied to the index page. The style sheet reference in index xhtml is:

<link href="#{facesContext.externalContext.requestContextPath}/resources/css/myStyles.css" rel="styleSheet" type="text/css"/>

I have tried adding the following style sheet ref but it made no difference:

<link href="/resources/css/m450.css" rel="styleSheet" type="text/css"/>  

Has anyone had to solve such a problem please?


The first one should work fine, although it can be simplified as

<link href="#{request.contextPath}/resources/css/myStyles.css" rel="styleSheet" type="text/css"/>

Rightclick the page in the webbrowser and choode View Source, is the EL been evaluated? If you're using Firefox, you can click on the href, does it show the right CSS? Turn on Firebug, check the Net tab, does the CSS get loaded properly?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜