0 Replies Latest reply on May 14, 2009 8:27 PM by lbabb

    Observing Identity.EVENT_LOGOUT alters navigation

      I'm new to Seam and have been trying a simple example to initialize a component called appUser upon listening to the built-in EVENT_LOGGED_OUT event which is raised during the #{identity.logout} action.


      I'm using JBoss 5.0.1 and Seam 2.1.1 and JBoss Tools 3.0 with Eclipse 3.4.


      I created the default Seam Web Project with the tool and ran it straight up with no issues.  When I login and logout, the navigation is setup to land me on the default generated /home.xhtml page based on the default generated pages.xml file from the JBoss Tools plugin as follows...


      <pages xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
             no-conversation-view-id="/home.xhtml"
             login-view-id="/login.xhtml">
           
          <page view-id="*">
              <navigation>
                  <rule if-outcome="home">
                      <redirect view-id="/home.xhtml"/>
                  </rule>
              </navigation>
          </page>
      ...
      



      The problem starts when I add the following class to the project...


      @Name("identityListener")
      public class IdentityListener
      {  
           @In Identity identity;
           @Out(scope=ScopeType.SESSION) ApplicationUser appUser;
           
           @Observer(Identity.EVENT_LOGIN_SUCCESSFUL)
           public void login()
           {
              appUser = ApplicationUserHelper.getApplicationUser(identity.getSubject());
           }
           
           @Observer(Identity.EVENT_LOGGED_OUT)
           public void logout()
           {
                appUser = null;
           }
      }
      



      Now when I run the project and hit the Logout link I end up navigating to the debug page after a short while with the url in the form .../myApp/debug.seam?cid=....  When I remove the @Observer(Identity.EVENT_LOGGED_OUT) the navigation works.


      I've tried a number of tricks like using the from-action="#{identity.logout}" and so on to get it to redirect to the /home.xhtml page, but no luck.  It appears as if the EVENT_LOGGED_OUT listener is causing the original to-view-id (or outcome) to get lost and I end up on the debug.seam page? 


      Any insights or solutions would be greatly appreciated.  Maybe observing the EVENT_LOGGED_OUT is a bad idea, but it seems like it shouldn't alter the default page flow?