6 Replies Latest reply on Apr 20, 2007 8:38 PM by sergeysmirnov

    How to reRender in a parent naming container?

    andrew.rw.robinson

      How can I re-render a component in a parent naming container without specifying a absolute path?

      Crude example:
      <a4j:form id="myform">
      <h:outputText id="a" />
      <f:subview id="b">
      <a4j:commandLink id="c" reRender="a" />
      </f:subview>
      </a4j:form>

      Client IDs:
      myform:a
      myform:b
      myform:b:c

      1) link is clicked
      2) link calls AjaxContext.addRegionsFromComponent
      3) AjaxContext internally calls convertId
      4) convertId calls UIComponent.findComponent
      5) find component gets the parent naming container ("myform:b")
      6) find component sees no myform:b:a and returns null
      7) "a" is not re-rendered

      I would use "..:a" if it was supported, but it is not. I really want to avoid absolute IDs since our application is quite complex and there isn't a guarantee that we won't change parent naming containers later.

      Is there any way to do this? If not can I propose an enhancement to AjaxContext:

       private String convertId(UIComponent component, String id) {
       if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
       return id;
       }
       if (null != component) {
       UIComponent target = null;
       for (UIComponent c = component; null != c && null == target; c = c.getParent())
       target = c.findComponent(id);
      
       if (null != target) {
       return AjaxRendererUtils.getAbsoluteId(target);
       }
       }
       return id;
       }
      


      This code would allow the ability to surf up the component tree looking for components with the given ID.