This is from the original question on stackoverflow.com:
http://stackoverflow.com/questions/8004233/jsf-2-how-to-pass-an-action-including-an-argument-to-be-invoked-to-a-facelets-s
As an example, this view:
<ui:param name="p1" value="#{myBean}" /> <ui:param name="p2" value="submit" /> <ui:param name="p3" value="#{myBean.toString()}" /> <h:form> <h:commandButton value="submit" action="#{p1[p2](p3)}" /> </h:form>
with this bean:
@ManagedBean @RequestScoped public class MyBean { public void submit(String arg) { System.out.println("submit with " + arg); } }
works fine on Tomcat 7.0.22, but on JBoss AS 7 it fails while loading the page:
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: /list.xhtml @164,66 action="#{p1[p2](p3)}": Method not found: com.company.project.beans.MyBean@67f400fb.submit() at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) at javax.faces.component.UICommand.broadcast(UICommand.java:315) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) at java.lang.Thread.run(Unknown Source) Caused by: javax.el.MethodNotFoundException: /list.xhtml @164,66 action="#{p1[p2](p3)}": Method not found: com.company.project.beans.MyBean@67f400fb.submit() at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) ... 26 more
Chapter 1.19 of EL spec says:
ValueSuffix ::= '.' Identifier MethodParameters? | '[' Expression ']' MethodParameters? MethodParameters ::= '(' (Expression (',' Expression )* )? ')'
So, I think that Apache EL is right. Please fix ASAP. This is often used/useful in lists where you have a DELETE button per list row.