2 Replies Latest reply on Aug 12, 2010 7:34 PM by tw

    commandLink with parameterized action attribute?

    tw

      I'm attempting to create a custom commandLink template to eliminate all the common parameters (reRender, limitToList etc.) that repeat throughout the application. The template would typically accept the action and associated markup for visualization as parameter. All works well except the most important part, there seems to be no way to dynamically assign / pass as parameter the action atttibute for a command link.

       

      <a:commandLink>

         ...

           <f:attribute name="value" value="#{value}" rendered="#{not empty value}"/>
           <f:attribute name="action" value="#{myBean.method(anotherBean.getParameters())}"/>

       

           <ui:insert/>

      </a:commandLink>

       

      What I would ultimately like to use is:

       

         <f:attribute name="action" value="#{action}" rendered="#{not empty action}"/>

       

      f:attribute seems to be ignored completely for 'action', though it works fine for 'value'.

       

      <a:commandLink action="#{action != null ? action : null}" >

         ...

           <f:attribute name="value" value="#{value}" rendered="#{not empty value}"/>

       

           <ui:insert/>

      </a:commandLink>

       

      Using the action attribute directly is no go also:

       

      Caused by: com.sun.facelets.tag.TagAttributeException: /WEB-INF/tags/menuLink.xhtml @21,4 action="#{action != null ? action : nullAction}" Not a Valid Method Expression: #{action != null ? action : nullAction}
           at com.sun.facelets.tag.TagAttribute.getMethodExpression(TagAttribute.java:144)
           at org.ajax4jsf.webapp.taglib.AjaxActionsRule$ActionMapper2.applyMetadata(AjaxActionsRule.java:72)

       

      So what is the solution to parameterize the action attribute? Note that bean[method] syntax won't help as the method needs to be able to accept parameters.