0

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
Steve Tee
  • 13
  • 3
  • [link]http://blog.oio.de/2013/01/29/problem-with-uirepeat-and-null-values-in-jsf-2-x/ Is there also an issue with resetting any EVH value on a component inside a ui:repeat ? That includes the assumption we can get hold of the target component in the first place which is my question above. ui:repeat is turning into a bit of a quagmire... – Steve Tee May 07 '13 at 10:35
  • http://stackoverflow.com/questions/13457295/how-to-address-a-component-inside-a-looping-naming-container I think the latter posting answers my question. Pays to read deep and wide before posting – Steve Tee May 07 '13 at 12:33
  • Also for anyone seeking a fix for an EVH value clear-out inside a ui:repeat bug mentioned in the previous but one comment, a fix for this issue has been included in Mojarra release v 2.1.21 (April 2013) – Steve Tee May 07 '13 at 12:35

0 Answers0