[jboss-user] [JBoss Seam] - How to dynamically navigate after identity.login()

JohnEChesher do-not-reply at jboss.com
Fri Mar 2 13:50:23 EST 2007


After successfully logging into my app using identity.login(), I want to dynamically direct the user to one of two pages, depending upon the permissions level of the user.  I have tried several options, none of which worked, and I'm about ready to implement the solution that I know to work - use a JPDL pageflow - but before I do, I was wondering if someone had an easier, more elegant way of implementing this common scenario.  Here are the attempts I have made thus far:

1) This does not produce an exception, but it always navigates back to the login page, so I assume Seam cannot handle nested navigation rules:
<page view-id="/login.xhtml">
  |   <navigation from-action="#{identity.login}">
  |     <rule if-outcome="loggedIn">
  |       <rule if="#{s:hasPermission('userAndInstitution','add', null)}">
  |         <redirect view-id="/AdminHome.xhtml"/>
  |       </rule>
  |       <rule if="#{not s:hasPermission('userAndInstitution','add', null)}">
  |         <redirect view-id="/UserHome.xhtml"/>
  |       </rule>
  |     </rule>
  |   </navigation>
  | </page>

2) The idea here was that I didn't need to check for outcome of "loggedIn", since the only other outcome is null, which would go immediately back to the previous page.  However, the expression parser  fails once it hits "s:":  
<page view-id="/login.xhtml">
  |   <navigation from-action="#{identity.login}">
  |       <rule if="#{s:hasPermission('userAndInstitution','add', null)}">
  |         <redirect view-id="/AdminHome.xhtml"/>
  |       </rule>
  |       <rule if="#{not s:hasPermission('userAndInstitution','add', null)}">
  |         <redirect view-id="/UserHome.xhtml"/>
  |       </rule>
  |   </navigation>
  | </page>

3) This was an attempt to access the identity permission method directly.  The expression parser throws an exception when it hits the "(": 
<page view-id="/login.xhtml">
  |   <navigation from-action="#{identity.login}">
  |       <rule if="#{identity.checkPermission('userAndInstitution','add', null)}">
  |         <redirect view-id="/AdminHome.xhtml"/>
  |       </rule>
  |       <rule if="#{not identity.checkPermission('userAndInstitution','add', null)}">
  |         <redirect view-id="/UserHome.xhtml"/>
  |       </rule>
  |   </navigation>
  | </page>

Any other ideas or commentary on what I have tried?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024730#4024730

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024730



More information about the jboss-user mailing list