> how can I get the radio's value to submit as well?
Use a valueChangeListener. Since the component is "immediate", you will
need to explicitly call the setter method for the property.
E.G.
public void updateState(ValueChangeEvent event) {
String newState = (String) event.getNewValue();
data.setCurrentState(newState);
}
You should also check out the wiki specifically on this topic: [1],
as well as the new submitOnEvent component [2].
[1] http://wiki.apache.org/myfaces/SubmitPageOnValueChange
[2] http://wiki.apache.org/myfaces/SubmitOnEvent
Regards,
Jeff Bischoff
Kenneth L Kurz & Associates, Inc.
monkeyden wrote:
Im using this wiki example to submit a form from a radio button:
http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces
http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces
The submit itself is working flawlessly and everything described in the
example is fine. I was wondering how I could also get the value of the
selected radio button passed to the listener method as well. I happen to be
using JBoss Seam components as the business layer, but the main question is,
how can I get the radio's value to submit as well? I've implemented it as
such:
The listener method:
@RequestParameter private String selectedState;
public String getSelectedState() {
return selectedState;
}
public void setSelectedState(String selectedState) {
this.selectedState = selectedState;
}
public String locationsByState(){
availableLocations = new ArrayList<SelectItem>();
loadLocations();
for(int i=0;i<staticLocations.size();i++){
SelectItem current = staticLocations.get(i);
if(current.getDescription().trim().equals(selectedState)){
availableLocations.add(current);
}
}
return display();
}
The View. radioSubmit is generating the JS event as in the example:
<h:selectOneRadio value="#{editProfileAction.selectedState}"
onmouseup="radioSubmit('hiddenLink');" styleClass="bodyCopy"
immediate="true">
<f:selectItem itemLabel="MA" itemValue="MA"/>
<f:selectItem itemLabel="ME" itemValue="ME"/>
<f:selectItem itemLabel="NH" itemValue="NH"/>
<f:selectItem itemLabel="RI" itemValue="RI"/>
<f:selectItem itemLabel="VT" itemValue="VT"/>
</h:selectOneRadio>
<t:commandLink id="hiddenLink" forceId="true" style="display:none;
visibility: hidden;" action="#{editProfileAction.locationsByState}">
</t:commandLink>
Thanks for any suggestions