将动作方法名称作为参数传递给facelets组件

|| 我正在调用模板,并传递如下参数:
<ui:include src=\"WEB-INF/Subviews/ProductEdit.xhtml\">
    <ui:param name=\"items\" value=\"#{produtList}\"></ui:param>
    <ui:param name=\"itemToEdit\" value=\"#{productToEdit}\"></ui:param>
</ui:include>
在ProductEdit.xhtml中,我有类似
<ui:repeat value=\"#{items}\" var=\"item\">
  <tr>
    ...
    ...
    <td style=\"text-align: center\">
      <h:commandLink style=\"cssGenericColumn\" action=\"#{productEditAction}\">
         <f:setPropertyActionListener target=\"#{itemToEdit}\" value=\"#{item}\"/>
      </h:commandLink>    
    </td>
  <tr>
</ui:repeat>
效果很好。 现在,我想在ProductEdit.xhtml中对#{productEditAction}进行参数化,因此我进行了以下操作
<ui:include src=\"WEB-INF/Subviews/ProductEdit.xhtml\">
    <ui:param name=\"items\" value=\"#{produtList}\"></ui:param>
    <ui:param name=\"itemToEdit\" value=\"#{productToEdit}\"></ui:param>
    <ui:param name=\"itemEditAction\" value=\"#{productEditAction}\"></ui:param>
</ui:include>
在第一页中,然后在ProductEdit.xhtml中
<ui:repeat value=\"#{items}\" var=\"item\">
  <tr>
    ...
    ...
    <td style=\"text-align: center\">
      <h:commandLink style=\"cssGenericColumn\" action=\"#{itemEditAction}\">
         <f:setPropertyActionListener target=\"#{itemToEdit}\" value=\"#{item}\"/>
      </h:commandLink>    
    </td>
  <tr>
</ui:repeat>
并且由于以下错误而失败
javax.faces.el.EvaluationException: /WEB-INF/Subviews/ProductEdit.xhtml @45,89 action=\"#{itemEditAction}\": Identity \'itemEditAction\' does not reference a MethodExpression instance, returned type: java.lang.String
at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:    at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:    at javax.faces.component.UICommand.broadcast(UICommand.java:109)....
 ....
 ....
 ....
但是,如果操作绑定到模型对象,则此方法有效。所以像
 <h:commandLink style=\"cssGenericColumn\" action=\"#{item.editAction}\">
有任何想法吗?     
已邀请:
将方法作为参数传递应采用以下方式:
itemBean=\"#{bean}\"
itemEditAction=\"productEditAction\"
并在您的组件中将它们放到gheter:
action=\"#{itemBean[itemEditAction]}\"
    
也许ActionMapperTagHandler可以工作。     

要回复问题请先登录注册