Requirment-valueChangeListener is not working on checkbox or SelectOneChoice in Oracle ADF
Solution-While working in ADF project, normally we have checkbox or SelectOneChoice , radio buttons (af:selectOneRadio) and list of values ie., LOVs etc.
when we wrote value change listener on it. everything seems to be perfect. but sometimes ,weird things happened in this world. our valueChangeListener is not getting called.It happend , if you using iterator or some varible in it. developer spent lot of times spending on it, why it is not called when everything seems to be correct.
You just need to do one change,.in your valueChangeListener add below code as first line.
valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
Thats it. It should work now.
Now let check out, what we have done here as by oracle doc.
processUpdates
public abstract void processUpdates(javax.faces.context.FacesContext context)- Perform the component tree processing required by the Update Model Values phase of the request processing lifecycle for all facets of this component, all children of this component, and this component itself, as follows.
If the rendered property of this UIComponent is false, skip further processing.
Call the processUpdates() method of all facets and children of this UIComponent, in the order determined by a call to getFacetsAndChildren().
Parameters:
context – FacesContext for the request we are processing
Throws:
java.lang.NullPointerException – if context is null
It process the component value in update model value phase of lifecycle.
Happy coding with Vinay in Techartifact ….. 🙂