valueChangeListener not executed only for a newly changed component. In fact, you use the JavaScript submit() function to submit the entire form. valueChangeListener will always be executed whenever the new selected value is different from the old value, as was declared in the value attribute.
You have not declared the value attribute, so its default value is effectively null . If the default list item is not null , then valueChangeListener will be called.
To fix this, you need to assign a value attribute to the component
<h:selectOneMenu value="#{careNeed.needsLevel}">
and , you need to pre-populate it with the same value as the default value for the drop-down list.
this.needsLevel = "not_assessed";
Alternatively, you can also make the default value null .
<f:selectItem itemValue="${null}" itemLabel="----Not assessed----"/>
Unrelated to the problem, since you are already using JSF 2.0, I suggest using <f:ajax> to send only the recently modified drop-down list using ajaxical powers instead of using onchange="submit()" to submit the entire form. This is better for users.
<h:selectOneMenu> <f:ajax /> </h:selectOneMenu>
In addition, the valueChangeListener method valueChangeListener not need to return anything. In any case, this will be ignored. Just declare it void .
source share