2 Replies Latest reply on Apr 12, 2010 2:24 AM by Chun Shin

    can navigation from-action method have parameters?

    Chun Shin Newbie

      Hi,


      I have the following navigation block in my pages.xml




              <navigation from-action="#{someBean.showDetails}">
                  <redirect view-id="/details.xhtml" />
              </navigation>



      The above works fine.


      However, when I changed the method showDetails to take a parameter like




              <navigation from-action="#{someBean.showDetails(rowIndex)}">
                  <redirect view-id="/details.xhtml" />
              </navigation>



      the redirect doesn't work. To get around this, I changed the method showDetails to return a string like




          public String showDetails(final String rowIndex) {
      
              // do something here
      
              return "/details.xhtml";
          }



      Can this be done in navigation from-action?


      Thanks for your help in advance!




        • 1. Re: can navigation from-action method have parameters?
          Pjot Andreev Newbie

          Hi James, normlly it works perfectly, if you use parameters in the action expression. One can even call the action method dynamically on some SEAM/JSF component:


          call the action



          <a4j:commandLink action="#{actionHandler[actionHandler.selectedAction]}"/>




          and navigate with


          <navigation from-action="#{actionHandler[actionHandler.selectedAction]}">
          ..
          </navigation>




          In your case the question is rather: are you sure the rowIndex is of type String? I guess, the EL expression


          #{someBean.showDetails(rowIndex)}



          doesnt get evaluated to the method


          showDetails(final String rowIndex) 




          And by the way, i would recommend a very nice book Seam In Action by Dan Allen, Chapter 2.5.1, where u can find very usefull info about drill downs.


          • 2. Re: can navigation from-action method have parameters?
            Chun Shin Newbie

            Pjot,


            Yes, I'm positive the rowIndex is type String. I have a rich:dataTable like



            <rich:dataTable id="d1" rowKeyVar="rowIndex">
            ...
            </rich:dataTable>



            I could have used @DataModelSelection for a selected row from the rich:dataTable, but I'm trying to not use @DataModelSelection. To achieve that, I came up with an idea of passing a row index when a user clicks an a4j:commandLink 'showDetails'. So, my a4j:commandLink looks like



            <a4j:commandLink id="l1" action="#{someBean.showDetails(rowIndex)}" value="Details" />



            In my showDetails method, I could see rowIndex is passed correctly.


            Odd, why the navigation doesn't work in pages.xml.