1 Reply Latest reply on Dec 16, 2011 6:44 PM by Brendan Healey

    RF 4.1.0.Final: Problem using columnResize with more than one extendedDataTable on the same page.

    Christian Peter Expert

      Hello,

       

      I've encountered some problems using richfaces extendedDataTables in RichFace 4.1.0.Final

       

      Here is the facelet:

       

      <h:form>

        <rich:extendedDataTable value="#{tableDemoManager.demoList}" var="item" frozenColumns="2" style="height:300px; width:500px;">

          <rich:column>

            <f:facet name="header">Header7</f:facet>

            #{item.name}

          </rich:column>

         

          <rich:column>

            <f:facet name="header">Header8</f:facet>

            #{item.uuid}

          </rich:column>

         

          <rich:column>

            <f:facet name="header">Header9</f:facet>

            #{item.uuid}

          </rich:column>

         

          <rich:column>

            <f:facet name="header">Header10</f:facet>

            #{item.uuid}

          </rich:column>

       

        </rich:extendedDataTable>

       

        </h:form>

       

      <h:form>

        <rich:extendedDataTable value="#{tableDemoManager.demoList}" var="item" frozenColumns="2" style="height:300px; width:500px;">

          <rich:column>

            <f:facet name="header">Header7</f:facet>

            #{item.name}

          </rich:column>

         

          <rich:column>

            <f:facet name="header">Header8</f:facet>

            #{item.uuid}

          </rich:column>

         

          <rich:column>

            <f:facet name="header">Header9</f:facet>

            #{item.uuid}

          </rich:column>

         

          <rich:column>

            <f:facet name="header">Header10</f:facet>

            #{item.uuid}

          </rich:column>

       

        </rich:extendedDataTable>

       

        </h:form>

       

       

      Resizing the columns on the first table works perfectly, but if someone tries to resize the second tables' columns as well, I've got NullPointer exceptions like:

      java.lang.NullPointerException

              at org.richfaces.renderkit.SortingFilteringRowsRenderer.updateAttribute(SortingFilteringRowsRenderer.java:135) [richfaces-components-ui-4.1.0.Final.jar:

              at org.richfaces.renderkit.ExtendedDataTableRenderer.updateWidthOfColumns(ExtendedDataTableRenderer.java:825) [richfaces-components-ui-4.1.0.Final.jar:]

              at org.richfaces.renderkit.ExtendedDataTableRenderer.doDecode(ExtendedDataTableRenderer.java:808) [richfaces-components-ui-4.1.0.Final.jar:]

              at org.richfaces.renderkit.RendererBase.decode(RendererBase.java:80) [richfaces-components-ui-4.1.0.Final.jar:]

              at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at org.richfaces.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:819) [richfaces-components-ui-4.1.0.Final.jar:]

              at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:53) [richfaces-core-impl-4.1.0.Final.jar:]

              at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:321) [richfaces-core-impl-4.1.0.Final.jar:]

              at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1319) [richfaces-components-ui-4.1.0.Final.jar:]

              at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at javax.faces.component.UIForm.visitTree(UIForm.java:344) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:237) [richfaces-core-impl-4.1.0.Final.jar:

              at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:217) [richfaces-core-impl-4.1.0.F

              at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:196) [richfaces-core-impl-4.1.0.Final.jar:]

              at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

       

       

       

       

       

       

      I've looked into the richfaces clientside javascript codes:

      RichFaces.ui.ExtendedDataTable.prototype.setColumnWidth = function (id, width) {

            console.log("setColumnWidth");

          width = width + "px";

          RichFaces.utils.getCSSRule("." + WIDTH_CLASS_NAME_BASE + id).style.width = width;

          this.newWidths = {}; // added by me!

          this.newWidths[id] = width;

          var widthsArray = new Array();

          for (var id in this.newWidths) {

              widthsArray.push(id + ":" + this.newWidths[id]);

          }

          console.log(this.newWidths);

          console.log(widthsArray);

          this.widthInput.value = widthsArray.toString();

          this.updateLayout();

          this.adjustResizers();

          this.ajaxFunction();

      }

       

      The interesting part is the this.newWidths = {}; object. I've added this line. Without it, this object will grow on each column resize. If you go the the second table, this object will not become cleared and therefore still contains the column resize data of the first table.

       

      After clearing the this.newWidths object, the resizing seems to work.

       

      But I'm not sure why to keep the data stored in the first place after the resizing is done.