0 Replies Latest reply on Jul 15, 2007 12:00 PM by Jim Ho

    a4j:repeat does not work well with SUN JSF 1.2 RI

    Jim Ho Newbie

      Environment: Tomcat 6.0.13 + JSF 1.2 RI + Ajax4JSF 1.1.1

      The bug is the client-side ids of elements inside a4j:repeat do not contain outer naming container's id.

      For example,

      <h:form id="ccc">
       <a4j:repeat id="rrr" value="#{bean.someModel}" var="element">
       <h:outputText id="eee" value="element.someAttribute" />
       </a4j:repeat>
      </h:form>

      should be encoded to
      <span id="ccc:rrr:_ROW_INDEX_:eee">...</span>

      but in JSF 1.2 RI case, it is encoded to
      <span id="rrr:_ROW_INDEX_:eee">...</span>

      This results in "deranged" ajax updates, e.g., action components inside
      a4j:repeat can not receive their own update message correctly.

      I had found the bug. When a4j:repeat is created from its tag handler's findcomponent() method, these methods will be invoked successively

      setProperties() -> setValue() -> setExtendedModel() -> getBaseClientId()

      The problem is setParent() is not called yet before setProperties(),
      that's why getBaseClientId() will return a id which doesn't contain the parent naming container's id.

      Here is my solution, patch on org.ajax4jsf.ajax.repeat.UIDataAdapter
      private boolean _reset;
      
      protected void resetDataModel() {
       _reset = true;
       this.setExtendedDataModel(null);
       _reset = false;
      }
      
      protected void setExtendedDataModel(ExtendedDataModel model) {
       if (this._currentModel == null && model == null && !_reset
       && this._modelsMap.size() == 0) {
       return;
       }
       this._currentModel = model;
       this._modelsMap.put(getBaseClientId(getFacesContext()), model);
      }