ajax4jsf
  1. ajax4jsf
  2. AJAX4JSF-6

IDs not handled correctly for components inside tables

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      6

      Description

      Ids for components to be reRendered are not correctly interpreted if the a4j
      component (and the component to be re-rendered) is inside a table. The row
      number component of the id is missed out causing the javascript rerendering to
      fail in locating the component to be updating. The following patch appears to
      fix the issue for me. I am unsure of any side effects, but have not noticed any
      so far. Have tested with JSF RI 1.2 and Facelets 1.1.8.

      diff -u -w -r java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
      javaPatched/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
      — java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java 2006-07-25
      13:43:46.000000000 +1000
      +++ javaPatched/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
      2006-07-26 16:14:48.765625000 +1000
      @@ -24,6 +24,7 @@

      import javax.faces.component.NamingContainer;
      import javax.faces.component.UIComponent;
      +import javax.faces.component.UIData;
      import javax.faces.context.FacesContext;

      import org.ajax4jsf.ajax.UILoadBundle;
      @@ -165,7 +166,8 @@
      // list for rendering may contains absolute id ( best ),
      // component Id or client ID
      String elementId = element.getId();

      • String absoluteId = currentPath + elementId;
        + String absoluteId = AjaxRendererUtils.getAbsoluteId(element);
        + // String absoluteId = currentPath + elementId;
        // String clientId = element.getClientId(context);
        if (ids.contains(absoluteId) || ids.contains(elementId)) {
        if (log.isDebugEnabled()) {
        @@ -190,8 +192,24 @@
        if(special) { element.encodeBegin(context); }

        +
        + // OVERRIDDEN CODE
        + // check for UIData, iterate through rows.
        + if (element instanceof UIData)

        Unknown macro: {+ UIData data = (UIData) element;+ + int i = 0;+ data.setRowIndex(i);+ while (data.isRowAvailable()) { + data.setRowIndex(i++); + encodeAjaxChild(context, element, currentPath, ids, + renderedAreas); + }+ data.setRowIndex(-1);+ }

        else

        { encodeAjaxChild(context, element, currentPath, ids, renderedAreas); + }

        if(special)

        { element.encodeEnd(context); }

        diff -u -w -r java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
        javaPatched/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java

          • java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2006-07-25
            13:43:48.000000000 +1000
            +++ javaPatched/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
            2006-07-26 16:06:11.578125000 +1000
            @@ -550,22 +550,26 @@
            throw new NullPointerException(Messages
            .getMessage(Messages.COMPONENT_NULL_ERROR_2));
      • StringBuffer idBuf = new StringBuffer();
        -
      • idBuf.append(component.getId());
        +// StringBuffer idBuf = new StringBuffer();
        +//
        +// idBuf.append(component.getId());
        +//
        +// UIComponent parent = component;
        +//
        +// while ((parent = parent.getParent()) != null)
        Unknown macro: {+// if (parent instanceof NamingContainer) { +// idBuf.insert(0, NamingContainer.SEPARATOR_CHAR); +// idBuf.insert(0, parent.getId()); +// }+// }

        +// idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
        +// log.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO,
        +// component.getId(), idBuf.toString()));
        +// return idBuf.toString();

      • UIComponent parent = component;
        + // OVERRIDEN CODE
        + return component.getClientId(FacesContext.getCurrentInstance());
      • while ((parent = parent.getParent()) != null) {
      • if (parent instanceof NamingContainer) { - idBuf.insert(0, NamingContainer.SEPARATOR_CHAR); - idBuf.insert(0, parent.getId()); - }
      • }
      • idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
      • log.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO,
      • component.getId(), idBuf.toString()));
      • return idBuf.toString();
        }

      /**

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            ajax4jsf-issues
            Reporter:
            timslater
          • Votes:
            3 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: