[jboss-user] [JBoss Seam] - Submitting using SelectOneRadio
monkeyden
do-not-reply at jboss.com
Mon Oct 30 12:38:17 EST 2006
I'm not sure where this should be posted, as it's in a grey area.
I'm using the following reference to submit using a SelectOneRadio.
http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces
Everything works as promised in the example (the listener method is called) but I have one other requirement. I need to value of the selected radio button to be passed to my listener method. My locationsByState() listener is traversing a cached list of SelectItems, to return the ones that have a description value of whatever @RequestParameter selectedState is. The problem is, selectedState is always null. I think I'm misunderstanding what happens when the commandLink is processed. I'm assuming the value would be submitted when the commandButton is programatically "clicked."
I have set it up in the Seam action as follows (staticLocations is a globally cached list of locations):
@RequestParameter
| private String selectedState;
|
| public List<SelectItem> locationsByState(){
| List<SelectItem> locationsByState = new ArrayList<SelectItem>();
| loadLocations();
| for(int i=0;i<staticLocations.size();i++){
| SelectItem current = staticLocations.get(i);
| //selectedState is always null
| if(current.getDescription().trim().equals(selectedState)){
| locationsByState.add(current);
| }
| }
| return locationsByState;
| }
|
|
In the view, radioSubmit() is generating a JS event for "hiddenLink", to call the listener method. Again, everything works exactly as expected.
<h:selectOneRadio value="#{editProfileAction.selectedState}" onmouseup="radioSubmit('hiddenLink');" styleClass="bodyCopy">
| <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>
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981836#3981836
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981836
More information about the jboss-user
mailing list