0 Replies Latest reply on Nov 22, 2010 5:54 PM by demetrio812

    Capture and return to CurrentView

    demetrio812 Apprentice

      Hello,
      the standard mechanism of Seam 2 to capture the view and return after the login work properly, but in my application I had to check the access rule to a specific page in a programmatic way (some time the page can be accessed by a non-logged user, sometimes only by logged users, etc...it depends on the type of element I'm going to show).


      So I've removed the login-required=true option from the .page.xml file of the page and I've added the following code:



      <restrict>#{myBean.myPermissionCheckMethod(myType)}</restrict>



      And from inside the myPermissionCheckMethod if the login is needed I call the following code:


      Events.instance().raiseEvent(SystemEventsConstants.USER_NOT_LOGGED_IN);
      
      throw new NotLoggedInException();



      By doing that, the event calls redirect.captureCurrentView (I debugged it and it works), it begin the conversation and the Exception redirect from the current page to the login page with the new lr conversation.


      The problem is that when the user execute the login and the method redirect.returnToCapturedView is called but the saved data is null.


      I also tried to create another session bean and it works but I would prefer not to use a session bean...


      Is there a way to make this pattern works? Is there another way?


      Thanks


      Demetrio