Reputation: 2491
Using JSF 2.0, Glassfish 3.2, Primefaces 2.2.1
I have a page with several composite components. In one of these components, I have an h:selectOneMenu. I am trying to add f:ajax to call a method when a new value is selected.
Here is what the h:selectOneMenu component in the page looks like:
<h:selectOneMenu id="selectRmDD" styleClass="editSelectRmDD" value="#{scheduleEditSessionBean.selectedRoom}" >
<f:selectItems id="roomList" value="#{scheduleEditSessionBean.roomList}"/>
<f:ajax listener="#{scheduleEditSessionBean.selectRmDD_processValueChange}" event="valueChange" render="@form" />
</h:selectOneMenu>
When I select a new item from the h:selectOneMenu, the listener function gets called, but the value in selectedRoom is null. I have looked at this in the debugger as well and even the submittedValue for the component in the AjaxBehaviorEvent is also null. Here is the method that is called when a new value is selected and the definition for selectedRoom:
public void selectRmDD_processValueChange( AjaxBehaviorEvent ae) {
String s = getSelectedRoom();
System.out.println( "Selected room = "+s );
if( s != null )applyRoomBtn_action();
}
private String selectedRoom = "1";
public String getSelectedRoom() { return this.selectedRoom; }
public void setSelectedRoom(String s) { this.selectedRoom = s; }
Any ideas why the value isn't being filled?
Thanks.
Upvotes: 0
Views: 2688
Reputation: 1109874
That will happen when the SelectItem
of the roomList
has null
or empty string as value at the point the form submit is been processed. No other causes comes to mind, expect of maybe a Converter
for String.class
which is not doing its job properly, but that should have affected all inputs which are bound to a String
property.
Upvotes: 1