2 Replies Latest reply on May 17, 2011 11:32 AM by su baochen

    variable as commandButton's action and xxx.page.xml

    su baochen Newbie

      Hi all,


      I have a commandButton in a snippet xhtml like this:




      <h:commandButton action="#{bean[action]}" />





      the bean and action are from:




      <ui:include src="path_to_commandButton_snippet">
          <ui:param name="bean" value="MyBean"/>
          <ui:param name="action" value="edit"/>
      </ui:include>





      And in page.xml, I have defined the rule like this:




          <navigation from-action="#{MyBean.edit}">
              <rule if-outcome="ok">
                  <redirect view-id="/AnotherPage.xhtml">
                      <message>OK</message>
                  </redirect>
              </rule>
          </navigation>





      But I noticed that, MyBean.edit is called, but can not navigated to AnotherPage.xhtml.


      If commandButton call MyBean.edit directly like this:




      <h:commandButton action="#{MyBean.edit}" />





      will go to AntherPage.xhtml after MyBean.edit result in ok.


      Anybody can give me some hints why indrect call to MyBean.edit will passby page.xml? Thanks in advance!

        • 1. Re: variable as commandButton's action and xxx.page.xml
          su baochen Newbie

          I'm sorry, the last sentence means, why indirect call to MyBean.edit will bypass xxx.page.xml? thanks!

          • 2. Re: variable as commandButton's action and xxx.page.xml
            su baochen Newbie
            I think it is because Seam Rule resolver can not understand EL expression #{bean[action]}, but only understand #{MyBean.edit}.

            I have traced into Pages.java(org.jboss.seam.navigation):


            `
               public boolean navigate(FacesContext context, String actionExpression, String actionOutcomeValue)
               {
                  String viewId = getViewId(context);
                  if (viewId!=null)
                  {
                     List<Page> stack = getPageStack(viewId);
                     for (int i=stack.size()-1; i>=0; i--)
                     {
                        Page page = stack.get(i);
                        Navigation navigation = page.getNavigations().get(actionExpression);
                        if (navigation==null)
                        {
                           navigation = page.getDefaultNavigation();
                        }
                       
                        if ( navigation!=null && navigation.navigate(context, actionOutcomeValue) ) return true; 
                       
                     }
                  }
                  return false;
               }`



            but can not get why #{bean[action]} can not be understood?  Any help? Thanks!