-
1. Re: Best way to redirect user after login, no specific loginpage
amitev Mar 16, 2010 3:35 PM (in response to troeng)Put the navigation rule in:
<page view-id="*">
-
2. Re: Best way to redirect user after login, no specific loginpage
troeng Mar 16, 2010 6:41 PM (in response to troeng)Simple as that, thanks! :)
-
3. Re: Best way to redirect user after login, no specific loginpage
hoangalain Apr 24, 2010 5:24 PM (in response to troeng)Hello,
Do you have a trick to redirect to same page that requires a login after user get through login page?
I do have several pages that requires login:
in pages.xml:
<page view-id="/page1.xhtml" login-required="true" > <rewrite pattern="/page1" /> </page> <!-- ... --> <page view-id="/page9.xhtml" login-required="true"> <rewrite pattern="/page9" /> </page>
<page view-id="/login.xhtml" action="#{''.toString()}" > <navigation from-action="#{''.toString()}"> <rule if="#{identity.login}"> <redirect view-id="/*"/> </rule> </navigation> <rewrite pattern="/login" /> </page>
the
<redirect view-id="/*"/>
does not work.
Do you have any suggestion?
See you,
Alain. -
4. Re: Best way to redirect user after login, no specific loginpage
mwohlf Apr 24, 2010 7:00 PM (in response to troeng)Hi Alain,
I had some trouble with the action="#{''.toString()}" hack in JSF2, so my setup in pages.xml looks like this:
<page view-id="/pages/login.xhtml" action="#{identity.isLoggedIn()}" conversation-required="false" login-required="false"> <description>login page</description> <navigation from-action="#{identity.isLoggedIn()}"> <rule if-outcome="true" > <redirect view-id="/pages/user/home.xhtml" /> </rule> <rule if-outcome="false" > <render view-id="/pages/login.xhtml" /> </rule> </navigation> </page>
to redirect to the page that required the login you need this in components.xml:
<!-- capture the view on the not login security event --> <event type="org.jboss.seam.security.notLoggedIn"> <action execute="#{redirect.captureCurrentView}"/> </event> <!-- redirect to the captured view after login --> <event type="org.jboss.seam.security.postAuthenticate"> <action execute="#{redirect.returnToCapturedView}"/> </event>
-
5. Re: Best way to redirect user after login, no specific loginpage
hoangalain Apr 26, 2010 2:47 AM (in response to troeng)Hello,
How could I use the redirect function like getViewID() from foo.xhtml in JBoss-Seam-Richfaces environment?
I try this:
<h:outputText value="Succesfull login: redirect to #{org.jboss.seam.faces.redirect.getViewId}."/>
I'm getting this error:
18:31:36,683 ERROR [viewhandler] Error Rendering View[/login.xhtml] javax.faces.FacesException: javax.el.PropertyNotFoundException: /login.xhtml @168,109 value="Succesfull login: redirect to #{org.jboss.seam.faces.redirect.getViewId}.": Property 'getViewId' not found on type org.jboss.seam.faces.Redirect at javax.faces.component.UIOutput.getValue(UIOutput.java:187)
Note: I did override the authenticate function. Should I add send of events like
org.jboss.seam.security.postAuthenticate
?See you,
Alain. -
6. Re: Best way to redirect user after login, no specific loginpage
mwohlf Apr 26, 2010 11:03 AM (in response to troeng)I am not sure what you try to do, but
<h:outputText value="Succesfull login: redirect to #{org.jboss.seam.faces.redirect.getViewId()}."/>
gets rid of the
Property 'getViewId' not found on type org.jboss.seam.faces.Redirect
error.
But this doesn't give you a redirect, it just prints some view id.
The
org.jboss.seam.security.postAuthenticate
event is triggered by Seam.