1 Reply Latest reply on Feb 9, 2012 5:25 AM by serkan

    Differentiate between link actions in page.xml

    billybojimbob

      Is it possible to have multiple actions for a single page URL depending on which link/button is clicked.
      The mypage.xhtml page has several columns of data and each column header has a link to adjust the sort by.
      Sample column headers are name, address, state, zip code, etc.


      On mypage.xhtml I've defined two links like this:


      <s:link action="#{mySessionBean.doNameSortAction}">
          #{messages['table.header.name']}
      </s:link>
      
      <s:link action="#{mySessionBean.doAddressSortAction}">
          #{messages['table.header.address']}
      </s:link>



      I want to have something like this in my pages.xml file:



      <page view-id="/mypage.xhtml">
          <!-- Default sort action -->
          <action execute="#{mySessionBean.doNameSortAction()}" />
          <navigation>
               <rule> <!-- sort by name -->
                  <action execute="#{mySessionBean.doNameSortAction()}" />
                  <redirect view-id="/mypage.xhtml"/>
              </rule>
      
               <rule> <!-- sort by address -->
                  <action execute="#{mySessionBean.doAddressSortAction()}" />
                  <redirect view-id="/mypage.xhtml"/>
              </rule>
          </navigation>
      </page>




      I realize that you can't have actions in rules but I'm not sure how to go about getting it to work while pointing the redirect to the same page URL and expecting a different action other than the default.



      <s:link action="name">
          #{messages['table.header.name']}
      </s:link>
      
      <s:link action="address">
          #{messages['table.header.address']}
      </s:link>





      Then I could refer to these different outcomes in my navigation rules:





      <page view-id="/mypage.xhtml">
          <!-- Default sort action -->
          <action execute="#{mySessionBean.doNameSortAction()}" />
          <navigation>
               <rule if-outcome="name">
                  <redirect view-id="/mypage.xhtml"/>
              </rule>
      
               <rule if-outcome="address">
                  <redirect view-id="/mypage.xhtml"/>
              </rule>
          </navigation>
      </page>



      Wouldn't this cause an infinite loop because I'm not able to define the specific action for the page because I'm redirecting to the same page?
      Without pointing to a new page each time I want to sort a column, how do I get this to work?


      Drew