With JSF 2 you should be able to do this:
<h:commandButton action="#{myBean.myAction(myParameter)}"/>
which would then call the action method, passing in the parameter (assume it's an Integer):
@ManagedBean
@SessionScoped
public class MyBean {
...
public String myAction(Integer myParameter) {
// do something
return null;
}
...
}
This works on Glassfish v3 perfectly. However not on Tomcat, you get an ELException notifying of the parse error
Caused by: javax.el.ELException: Error Parsing: ...
Now, there's a documented way of making this work using EL 2.2 and Glassfish's implementation by replacing the el-api
jar in the Tomcat lib directory, however I still get the same error occurring with no luck. Tomcat's really starting to frustrate me! JSF2 is meant to be easier!
Maven POM fragments:
<repositories>
<repository>
<id>sun</id>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>jboss</id>
<url>http://repository.jboss.com/maven2/</url>
</repository>
</repositories>
...
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>