selectOneRadio valueChangeEvent not firing
843844Feb 20 2007 — edited Feb 21 2007I am very frustrated with trying to get the value of a selectOneRadio button to work with a valueChangeListener. I have read most of the forum posts and followed all the applicable examples, but it doesn't work and I don't see how it should work.
Here is my jsp code:
<h:selectOneRadio id="userGroupType" value="#{EditUserGroupPage.userGroupType}" immediate="true"
onchange="submit()" valueChangeListener="#{EditUserGroupPage.changeUserGroupType}">
<f:selectItems id="userGroupType" value="#{EditUserGroupPage.userGroupTypes}"/>
</h:selectOneRadio>
Here is my valueChangeListener:
public void changeUserGroupType(ValueChangeEvent event){
System.out.println("detected a value change event.");
Long newValue = (Long)event.getNewValue();
setUserGroupType(newValue);
FacesContext context = FacesContext.getCurrentInstance();
context.renderResponse();
}
And here is my SelectItems array setter which populates the jsp.
private SelectItem[] userGroupTypes = {
new SelectItem(new Long("1"), "User Name Group"),
new SelectItem(new Long("2"), "Ip User Group")
};
public SelectItem[] getUserGroupTypes() {
return userGroupTypes;
}
The name of the value that I want is userGroupType.
/**
* Holds value of property userGroupType.
*/
private Long userGroupType;
public Long getUserGroupType(){
return this.userGroupType;
}
/**
* Setter for property userGroupType.
* @param userGroupType New value of property userGroupType.
*/
public void setUserGroupType(Long newValue) {
this.userGroupType = newValue;
}
Maybe I don't get it. I'm a little tired of having to do all this manipulation when since 1994 it's been pretty straightforward in the html spec.
So does anyone have any ideas here? I hope my tone is not bad, but I am very frustrated after almost two days of hacking around with this "used to be simple" task.
Please help. The valueChangeListener is never invoked. I can't see how it would be when I look at the actual output of the radio buttons because even though I've specifed the id in selectOneRadio as userGroupType, the actual radio button ids are written with an array position appended (userGroupType:0, userGroupType:1).
..\W