Search code examples
jsf-2seam3

Configure @Viewconfig Seam faces 3


I'm working on a simple project. My site will have only 2 pages. The front page, with the ogin and register controls, and a user page, that the user will be redirected after logged in or registered. I have some questions:

How can I implement a remember me feature with seam 3?

How can I automatic redirect a logged in user to the user page?

When the user click logoff, how can I redirect him to the front page?

Thanks


Solution

  • The easiest way to make redirect after logoff action and automatic redirect a logged in user is navigation rule. You can write this rules in faces-config.xml for example:

    <navigation-rule>
        <from-view-id>*</from-view-id>
    
        <navigation-case>
            <from-action>#{identity.logout}</from-action>
            <if>#{true}</if>
            <to-view-id>/frontPage.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>