The goal is to clear text field content based on drop down list selection via ajax. All components are located inside a ui:repeat.
I used the EditableValueHolder & clearValue() technique to reset field values updated via Ajax but not submitted.
I have the process working for non-repeating components.
When I try to apply the same listener to components inside a ui:repeat component, the ids returned by
partialViewContext.getRenderIds()
return a "null" from
UIVewRoot.findComponent(renderId)
I am unable to clear the content of these repeating fields using this technique
Why are the component ids not locatable in the search of UIViewRoot ?
public void clearModelValuesViaAjax(AjaxBehaviorEvent e) throws AbortProcessingException {
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
PartialViewContext partialViewContext = facesContext.getPartialViewContext();
for(String renderId:partialViewContext.getRenderIds()) {
if (renderId.contains("Other")) {
EditableValueHolder renderComponent = null;
String[] containers = renderId.split(":");
if (containers.length <=2) {
renderComponent = (EditableValueHolder) root.findComponent(renderId); /*NON REPEATING COMPONENTS */
} else {
renderComponent = (EditableValueHolder) root.findComponent(containers[0] + ":" + containers[containers.length-1]);
}
if (renderComponent != null) renderComponent.resetValue();
} etc