commandButton method binding problem

Hello,

I have a problem that I have managed to isolate in the following code. The method Bean.submit which is bound as an action to a commandButton does not get executed:

Java:

publicclass Bean{

public Bean(){

}

public String submit(){

return"Hello";

}

privateint selection;

publicint getSelection(){

return selection;

}

publicvoid setSelection(int selection){

this.selection = selection;

}

}

JSP:

<h:selectOneMenu id="menu" value="#{bean.selection}">

<f:selectItem itemValue="0" itemLabel="0" />

<f:selectItem itemValue="1" itemLabel="1" />

</h:selectOneMenu>

<h:commandButton id="button" value="Submit" action="#{bean.submit}" />

However, if I remove the binding of the selectOneMenu, Bean.submit does get executed:

<h:selectOneMenu id="menu" >

<f:selectItem itemValue="0" itemLabel="0" />

<f:selectItem itemValue="1" itemLabel="1" />

</h:selectOneMenu>

<h:commandButton id="button" value="Submit" action="#{bean.submit}" />

Any thoughts? Appreciate your help.

[2362 byte] By [abdousa] at [2007-10-3 2:31:01]
# 1
Looks like your setSelection method is accepting "int". Change it to String and try again. Before it even calls the action method, there is an error. So before the invoke application phase, error is occuring and causing the lifecycle to break.
kirangunduraoa at 2007-7-14 19:29:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thank you very much. This seems to have done the trick.
abdousa at 2007-7-14 19:29:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Rather use Integer instead of int (and String).JSF get/set values don't accept numeric datatypes, but Objects or booleans only. So use Integer, Double, Byte, Long, etc, instead of int, double, byte, long, etc.
BalusCa at 2007-7-14 19:29:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...