Make sure you are using the following import:
----
import javax.faces.event.ValueChangeEvent;
----

As well as the following method signature:
----
public void myMethod(ValueChangeEvent event) {...}
----

And call it like:
----
valueChangeListener="#{myBean.myMethod}"
----

That's about all there is to it. :)

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.

monkeyden wrote:
Can someone point me to some resource that describes how JSF handles the
valueChangeListener atttribute?
In my code, I have added it to a <h:selectOneRadio> and implemented the
method in my backing bean as myMethod(ValueChangeEvent evt).  When I have
the param, it gives a NoSuchMethodException but when I take the param out it
calls it just fine.  Tells me that JSF is not expecting the parameter.

It's my understanding that JSF creates the ValueChangeEvent and passes it to
the specified method.  Is this true?



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




Reply via email to