0 Replies Latest reply on Feb 18, 2009 4:28 PM by Eleas

    Navigation redirects problem in pages.xml

    Eleas Newbie

      I have have to pages edit and view for my entity Report. Report entity should be created from another entity of type Order. So I have somewhere link like this:



      <s:link viewId="/model/editreport.xhtml" value="Create report">
          <f:param name="orderId" value="#{orderInstance.orderId}"/>
      </s:link>




      In pages.xml I have:


         

      <page view-id="/model/editreport.xhtml">
              <param name="reportId" value="#{reportHome.id}" converterId="javax.faces.Long"/>
              <param name="orderId" value="#{reportHome.orderId}" converterId="javax.faces.Long"/>
          </page>



      AND(!!!) Everything is OK. I mean that orderId setted to reportHome, used for some actions (for example generating title of report from title of order) and then saved as reference in report.


      But as you can see according pages.xml - user will be redirected to the same page - editreport.xml. But I wish after user click Create rederect him to /bmodel/viewreport.xhtml. To do that I change only(!!!) pages.xml in such way:


         

      <page view-id="/bmodel/editreport.xhtml">
              <action execute="#{navigation.setCurrentObject(reportInstance)}"/>
              <restrict>#{s:hasRole('ADMIN') or currentUser == reportInstance.author or !reportHome.managed}</restrict>
              <param name="reportId" value="#{reportHome.id}" converterId="javax.faces.Long"/>
              <param name="orderId" value="#{reportHome.orderId}" converterId="javax.faces.Long"/>
              <navigation from-action="#{reportHome.persist}" >
                  <rule if-outcome="persisted">
                      <redirect view-id="/bmodel/viewreport.xhtml">
                          <param name="reportId" value="#{reportInstance.reportId}" converterId="javax.faces.Long"/>
                      </redirect>
                  </rule>
              </navigation>
              <navigation from-action="#{reportHome.update}">
                  <rule if-outcome="updated">
                  <redirect view-id="/bmodel/viewreport.xhtml">
                      <param name="reportId" value="#{reportInstance.reportId}" converterId="javax.faces.Long"/>
                  </redirect>
                  </rule>
              </navigation>
          </page>



      What is a result? When user firstly redirected to edit page - all looks good! But when hi clicks Create reportHome doesn't recive orderId and as a result created report doesn't have any reference to order! It looks like editreport on second request to server (when user click create) doesnt' recieve orderId at all. Where is the difference? where is a problem?


      A part of pages.xml for viewreport.xhtml:


      <page view-id="/bmodel/viewreport.xhtml">
              <param name="reportId" value="#{reportHome.id}" converterId="javax.faces.Long"/>       
          </page>



      Please help me to resolve this problem!