1 Reply Latest reply on Aug 21, 2008 1:48 AM by Scott Olcott

    endAndRedirect in pages.xml?

    Jesse Sweetland Newbie

      Is there any way to effect a Conversation.endAndRedirect in pages.xml?  For example:


      <page view-id="page1.xhtml" conversation-required="true">
          <navigation from-action="#{contactManager.newContact}">
              <rule if-outcome="success">
                  <begin-conversation nested="true"/>
                  <render view-id="newContact.xhtml"/>
              </rule>
          </navigation>
      </page>
      
      <page view-id="page2.xhtml" conversation-required="true">
          <navigation from-action="#{contactManager.newContact}">
              <rule if-outcome="success">
                  <begin-conversation nested="true"/>
                  <render view-id="newContact.xhtml"/>
              </rule>
          </navigation>
      </page>
      
      <page view-id="newContact.xhtml" conversation-required="true">
          <navigation from-action="#{contactManager.saveNewContact}">
              <rule if-outcome="success">
                  <!-- endAndRedirect to go back to either page1.xhtml or page2.xhtml depending on who called me -->
              </rule>
          </navigation>
      </page>



      Note that the following do not work:


      <end-conversation/>
      <redirect/>



      Nor:


      <end-conversation before-redirect="true"/>
      <redirect/>



      One way I can think of (sort of hackish) would be to use the if attribute of <rule> to invoke a backing bean method that does nothing but call Conversation.instance().endAndRedirect() and return true, but that breaks the if-outcome paradigm that I'm using.  Any other suggestions?


      Thanks,
      Jesse

        • 1. Re: endAndRedirect in pages.xml?
          Scott Olcott Newbie

          another hack would be to do something like this:


          <navigation from-action="#{contactManager.saveNewContact}" evaluate="#{conversation.endAndRedirect()}">
          <!--If a redirect does not occur redirect to a default page -->
                <rule if-outcome="false">
                  <redirect view-id="/someotherpage.xhtml" />
                </rule>
              </navigation>