1 Reply Latest reply on Jun 14, 2007 3:42 PM by monkeyden

    captureCurrentView

    monkeyden

      Having some trouble with captureCurrentView().

      The use case is:
      Actor is on any page within the application. Let's call it "Page A".
      Actor clicks the "Sign Up" link
      Actor is presented with the "Sign Up" page
      Actor enters necessary info and selects "Submit"
      Actor is brought to the "Sign Up Confirm" page, which displays a "Continue" button
      Actor selects the continue button and is brought back to Page A.

      I have an RegisterAction:

      @Name("registerAction")
      @Scope(CONVERSATION)
      public class RegisterAction{
       @Begin
       public String begin(){
       redirect.captureCurrentView();
       return "signupPage";
       }
      
       public String register() {
       //create records
       ....
      
       //explicitly log the user in
       identity.setUsername(user.getUserName());
       identity.setPassword(user.getUserPassword());
       loginAction.login();
       result = "confirm";
       }
      
       @Create
       public void create(){
      
       }
      
       @End
       public String takeMeBack(){
       redirect.returnToCapturedView();
       return null;
       }
      }



      I have a commandLInk which points to begin()
      <ice:commandLink id="signUpLink" value="#{messages['personalizationBar.label.signUp']}" action="#{registerAction.begin}"></ice:commandLink>


      And I have a commandButton on the Confirm page, which points to takeMeBack()

      <ice:commandButton id="continueButton"
      image="images/btn_continue.gif"
      onmouseover="javascript:this.src='images/btn_continue_hover.gif'"
       onmouseout="javascript:this.src='images/btn_continue.gif'"
      
      action="#{registerAction.takeMeBack}"/>
      



      I also have navigation rules in pages.xml

      <page view-id="/userMaintenance/signup.xhtml">
       <navigation from-action="#{registerAction.register}">
       <rule if-outcome="confirm">
       <redirect view-id="/userMaintenance/signupConfirm.xhtml" />
       </rule>
       <rule if-outcome="failure">
       <redirect view-id="/userMaintenance/signup.xhtml" />
       </rule>
       </navigation>
       </page>
      


      The problem is, it appears that Seam is redirecting to the captured view after the register() method, when I return "confirm", rather than when the "Continue" button calls takeMeBack(). I wouldn't expect Seam to do the redirect automatically ever, but if it did, I wouldn't expect it to happen until after @End is encountered.

      Any clues? Am I misunderstanding how captureCurrentView works?

      Thanks

        • 1. Re: captureCurrentView
          monkeyden

          Ok, it's definitely calling returnToCapturedView() automatically after the register() method is called. Can anyone tell me why @Begin and @End aren't being honored?