How do I add a URL parameter to redirected login page using JSF 2.0

Posted by Big Al on Stack Overflow See other posts from Stack Overflow or by Big Al
Published on 2012-06-19T21:05:03Z Indexed on 2012/06/19 21:16 UTC
Read the original article Hit count: 369

Filed under:

I have a question about session timeouts and JSF 2. I have my exception handler working exactly the way everyone prefers but I need to pass a value to the login page. For example, I have a typical login URL - www.acme.com/?companyId=company14 which in turn presents company14 with their own custom login page (using their logo). After they enter the application and do a bit of work, they read an email or 2. The session times out and a session timeout page is shown instructing the user to click Ok to proceed to the login page. How do I add ?companyId=company14 to the URL? I can hardcode it in the exception handler by using this:

requestMap.put("companyId", "company14");

and then referring to it on the viewExpired.xhtml page:

    <h:panelGrid id="expiredGrid" columns="1">
        <f:facet name="header">
            <h:outputText id="outExpireMsg" value="Your session has expired"/>
        </f:facet>
        <h:outputText id="outReqMessage" value="Reloading the page will require login."/>
        <h:outputText value=""/>
        <h:button id="okButton" type="submit" value="Ok" outcome="login?companyId=#{companyId}"/>
    </h:panelGrid>

The issue is I can't seem to save the companyId anywhere without it getting wiped out by the session timeout. I'd like to set the companyId in the exceptionhandler using this value. Any ideas?

© Stack Overflow or respective owner

Related posts about jsf-2.0