1 Reply Latest reply: Jun 14, 2012 12:51 PM by Andrey Zhemoytuk RSS

    Data Iteration components evaluate value on postback even if not rendered

    Andrey Zhemoytuk Newbie

      Value of dataTable gets evaluated on postback even when not rendered.

       

      Reproduced on RichFaces 4.2.2.Final with following example:

       

        <h:form>
          <a4j:outputPanel rendered="false">
      
            <rich:dataTable value="#{bean.shouldNotBeInvoked}">
            </rich:dataTable>
      
          </a4j:outputPanel>
      
          <a4j:commandButton value="Generate Postback" execute="@this"/>
        </h:form>
      

       

       

      Stacktrace:

       

      2012-06-12 19:41:14,064 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--0.0.0.0-8543-39) Error Rendering View[/test.xhtml]: javax.el.ELException: /test.xhtml @14,69 value="#{bean.shouldNotBeInvoked()}":
          at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at org.richfaces.component.UISequence.getValue(UISequence.java:175) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.component.UISequence.createExtendedDataModel(UISequence.java:109) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.component.UIDataTableBase.createExtendedDataModel(UIDataTableBase.java:231) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:459) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:272) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1299) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at javax.faces.component.UIForm.visitTree(UIForm.java:344) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1601) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorComponent(ExtendedPartialViewContextImpl.java:440) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorAtRender(ExtendedPartialViewContextImpl.java:326) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialRenderPhase(ExtendedPartialViewContextImpl.java:245) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]
          at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:194) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]
          at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:391) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
          at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
          at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:88) [jboss-seam.jar:2.3.0.Beta1]
          at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
          at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
          at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
      

       

       

      UPDATE:

       

      Impact is wider, not just rich:dataTable but all components which extend UIDataAdaptor. Namely:

      rich:extendedDataTable

      rich:dataTable

      rich:dataGrid

      rich:collapsibleSubTable

      rich:list

      rich:tree

      a4j:repeat

        • 1. Re: Data Iteration components evaluate value on postback even if not rendered
          Andrey Zhemoytuk Newbie

          similar jira issue:

          https://issues.jboss.org/browse/RF-11382

           

          Problem appears to be in org.richfaces.component.UIDataAdaptor class.

          Without patching RF sources the following workaround is possible (workaround should be repeated on every component extending UIDataAdaptor):

          public class UIDataTableWorkaround extends UIDataTable {

            @Override

            public void setRowKey(FacesContext facesContext, Object rowKey) {

              if (rowKey == null && getRowKey() == null) {

                return;

              }

              super.setRowKey(facesContext, rowKey);

            }

          }

           

          and in faces-config:

            <component>

              <component-type>org.richfaces.DataTable</component-type>

              <component-class>com.example.UIDataTableWorkaround</component-class>

            </component>