I'm trying to write a generic method to clear all fields content in a JSF component, in HTML, e.g. a panelGroup. If I have a panel group with fields A, B, C, I wanna per my view find the related fields in the backing bean and set it to null in the server side, Is it possible? For now I have this method:
public String clear(final String parentComponentId) {
UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
UIComponent fc = view.findComponent(parentComponentId);
if (null != fc) {
List<UIComponent> components = fc.getChildren();
for (UIComponent component : components) {
if (component instanceof UIInput) {
UIInput input = (UIInput) component;
input.resetValue();
}
}
}
return null;
}
But I think that the UIInput.resetValue() does not set the value on the server side...
PS: Just trying to put it more clear, the final goal is to set all components that are not rendered (rendered="false") automatically as null in the backing bean.