I'm using JSF 2.0 with primefaces over JBoss 7. In some part of the code, I have the following:
public void setItemValue(int value) {
this.value = value;
}
and in the xhtml:
<p:commandButton ajax="true" value="Button" update="@form"
action="#{bean.setItemValue(1)}"/>
The problem is, when I click the button, I get an javax.el.MethodNotFoundException
, saying that setItemValue(java.lang.Long)
doesn't exists. Off course it doesn't, it should be a int or Integer value! Anyone has seen this problem? there is any alternative other than changing my method to receive a long? Thanks!
EDIT: Just downloaded the SNAPSHOT of JBoss 7.2, and it works fine on it. Looks like its a bug of JBoss 7.1.1 :(
The method expression type for action is
String action()
So use
See also:
UPDATE You need to declare the Servlet version as 3.0 to take full advantage of the EL 2.2 such as passing the parameter. For that change your web-app element in your web.xml to this:
It looks a bit strange, but you can call the method intValue on the Long object self inside EL 2.2
Apologies for resurrecting this ancient thread. If you are still using Jboss 7.11 or hit similar issues and don't want to go the EL (1).intValue() route, you can also jippo your way around it in your managed bean as follows :-
Don't use
get
orset
prefix in any bean methods (Its a really bad practice) ,action
attribute expects a method name rather than some getter or setterget
andset
are used only for getters and setters of your bean variablesBetter replace your
setItemValue
with something likeassignItemValue
like this:
where