8 Replies Latest reply on Apr 9, 2014 7:27 AM by Michal Petrov

    RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table

    Hardy Massen Novice

      Hi,

       

      we have multiple extendedDataTables in a page. Only one table is rendered at any one time:

       

      <h:panelGroup id="A" rendered="#{controllerBean.switch == 'true'}">

                <ui:include src="snippetWithTableA.xhtml" />

      </h:panelGroup>

       

      <h:panelGroup id="B" rendered="#{controllerBean.switch == 'false'}">

                  <ui:include src="snippetWithTableB.xhtml" />

      </h:panelGroup>

       

      All columns of all tables have the sortBy-attributes set. If the snippet containing the first table is not rendered and if the first table contains a column, that has a sortOrder defined (e.g. sortOrder="descending") the sorting of all columns of the second table (the one, that is rendered) fails although the first snippet (<h:panelGroup id="A">) is not rendered. The extendedDataTable tries to sort the second table by a column of the first table (by the column, that has a sortOrder). Is this a known issue?

       

      I had expected, that the table in snippetWithTableA.xhtml does not have any effect on the table in snippetWithTableB.xhtml, because snippetWithTableA.xhtml is not rendered. Even if both snippets would have been rendered I think the sortOrder of the first one should not influence the second table, which may have its own sortOrder.

       

      snippetWithTableA.xhtml looks like this:

       

      <ui:composition>

                                            

      <rich:extendedDataTable id="tableA" value="#{controllerBean.itemListA}" var="b" selectionMode="none" sortMode="single">                                      

            

              <rich:column sortBy="#{b.datum}" sortOrder="descending">

                  <f:facet name="header">

                      <h:outputText value="#{msg.datum}" />              

                  </f:facet>

                  <h:outputText value="#{b.datum}" />

              </rich:column>              

            

      </rich:extendedDataTable>

        

      </ui:composition>

       

       

      snippetWithTableB.xhtml looks like this:

       

      <rich:extendedDataTable id="tableB" value="#{controllerBean.itemListB}" var="b" selectionMode="none" sortMode="single">                                      

            

              <rich:column sortBy="#{b.whatever}">

                  <f:facet name="header">

                      <h:outputText value="#{msg.whatever}" />              

                  </f:facet>

                  <h:outputText value="#{b.whatever}" />

              </rich:column>              

            

      </rich:extendedDataTable>

       

      The stacktrace:

       

      10:31:13,734 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-/0.0.0.0:8080-9) /pages/snippetWithTableA.xhtml @39,111 sortBy="#{b.datum}": The class 'itemListBItem' does not have the property 'datum'.: javax.el.PropertyNotFoundException: /pages/snippetWithTableA.xhtml @39,111 sortBy="#{b.datum}": The class 'itemListBItem' does not have the property 'datum'.

          at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]

          at org.richfaces.model.ArrangeableModel.compare(ArrangeableModel.java:299) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.model.ArrangeableModel.access$200(ArrangeableModel.java:51) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.model.ArrangeableModel$2.compare(ArrangeableModel.java:255) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324) [rt.jar:1.7.0_40]

          at java.util.TimSort.sort(TimSort.java:203) [rt.jar:1.7.0_40]

          at java.util.TimSort.sort(TimSort.java:173) [rt.jar:1.7.0_40]

          at java.util.Arrays.sort(Arrays.java:659) [rt.jar:1.7.0_40]

          at java.util.Collections.sort(Collections.java:217) [rt.jar:1.7.0_40]

          at org.richfaces.model.ArrangeableModel.sort(ArrangeableModel.java:253) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.model.ArrangeableModel.arrange(ArrangeableModel.java:207) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.component.UIDataTableBase.createExtendedDataModel(UIDataTableBase.java:265) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:459) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:272) [richfaces-components-ui-4.3.5.Final.jar:4.3.5.Final]

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

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIForm.visitTree(UIForm.java:362) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorComponent(ExtendedPartialViewContextImpl.java:493) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorAtExecute(ExtendedPartialViewContextImpl.java:354) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.context.ExtendedPartialViewContextImpl.getExecuteIds(ExtendedPartialViewContextImpl.java:117) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]

          at org.richfaces.context.ExtendedPartialViewContextImpl.isExecuteAll(ExtendedPartialViewContextImpl.java:167) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]

          at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:921) [jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar:2.1.19.1.Final-redhat-1]

          at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]

          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]

          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]

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

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:499) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:373) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:408) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]

          at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]

       

       

       

       

        • 1. Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
          Michal Petrov Master

          Hi,

           

          there doesn't seem to be anything wrong with the code. Are you sure you're retrieving the right data? And what's the data type of controllerBean.switch? There might be an error in there.

          • 2. Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
            Hardy Massen Novice

            The rendered="#{controllerBean.switch == 'true'}"-logic is working correctly. I've checked the resulting JSF-component tree with <ui:debug>.

             

            In the generated HTML-Code only one snippet is rendered as HTML, in the JSF-component tree all Snippets have their JSF-Components, but here only one <h:panelGroup> (containing one snippet) has the attribute rendered=true at any one time. All child-JSF-Components of the other disabled <h:panelGroups> have there rendered attribute set to true. I assume the error lies here, the UI-Column-Component is processed though one of it's parent-Components is set to rendered=false.

             

            If I duplicate the rendered="#{controllerBean.switch == 'true'}"-Logic on the <rich:column> that has the sortOrder="descending" set everything works fine.

             

            If I change the order of the snippets like this...

             

            <h:panelGroup id="B" rendered="#{controllerBean.switch == 'false'}">

                        <ui:include src="snippetWithTableB.xhtml" />

            </h:panelGroup>

             

            <h:panelGroup id="A" rendered="#{controllerBean.switch == 'true'}">

                      <ui:include src="snippetWithTableA.xhtml" />

            </h:panelGroup>

             

            ...a sortOrder=descending-setting in snippetWithTableB will cause an error in snippetWithTableA.

             

            If I remove the sortOrder=descending-setting completly it works.

             

            I checked, that I retrieve the right data. All Tables have different id's but have the same value, they go at the same list in the backing-bean, but at runtime this list contains different types. This code worked with RichFaces 3, I don't think there is any error here.

            • 3. Re: Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
              Michal Petrov Master

              Ah, apparently <ui:include> being processed even though the parent is not rendered is intentional.

               

              You can get around it with something like this:

               

              <h:panelGroup>
                   <ui:include src="#{controllerBean.switch ? 'snippetWithTableA.xhtml' : 'snippetWithTableB.xhtml'}" />
              </h:panelGroup>
              
              1 of 1 people found this helpful
              • 4. Re: Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
                Hardy Massen Novice

                Do you have any links that discuss the processing of render-disabled components? On first sight I can't see any reason for this behaviour.

                 

                But even if that is intentional it makes no sense that one sort-order setting in one table should disturb the sorting of another table. That would mean only one column, with the sortOrder-Attribute set, is allowed for all extendedDataTables (rendered or not) on a page and all elements shown in all extendedDataTables must contain the property, where the sortOrder is defined.

                 

                Do you have an idea, to get around this, if I have more snippets? Like 5?

                • 5. Re: Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
                  Michal Petrov Master

                  The thing is <ui:include> is processed before the rendering starts (and @rendered is checked). See here.

                   

                  I was unable to replicate the behavior, there might be issues with bean scope or data retrieval. Can you provide a short working example? (SSCCE)

                   

                  What are you doing with those 5 snippets? Showing one at a time? You an use <c:choose> for that, or an ApplicationScoped bean that will hold the link to the page, so you end up with <ui:include src="#{bean.page}" />

                  • 6. Re: Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
                    Hardy Massen Novice

                    Hi,

                    I mimimized the code.

                     

                    It seems, that the edt ties sorting-props to its value.

                     

                    If both edt have different element-lists (= different values), it works.

                    If at runtime the list doesn't have 2 or more elements, it works.

                    If I remove the sortOrder="descending" from the first list, it works.

                    If I add a rendered="false" at the rich:column of the first list, it works.

                     

                    The scope of the bean doesn't matter. The form doesn't matter, if I put each edt in a separate form it doesn't work neither.

                    Can you now reproduce it?

                     

                     

                    The Page:

                     

                    <?xml version="1.0" encoding="utf-8"?>

                    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"

                        xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">

                     

                    <h:head />

                    <h:body>

                     

                        <h:form>

                     

                            <h:panelGroup rendered="false">

                                <rich:extendedDataTable id="tableA" value="#{myController.someList}" var="a">

                                    <rich:column sortBy="#{a.somePropertyNotInCurrentList}" sortOrder="descending">

                                    </rich:column>

                                </rich:extendedDataTable>

                            </h:panelGroup>

                     

                            <rich:extendedDataTable id="tableB" value="#{myController.someList}" var="b">

                                <rich:column sortBy="#{b.bytes}">

                                    <f:facet name="header">

                                        <h:outputText value="Heading" />

                                    </f:facet>

                                    <h:outputText value="#{b.bytes}" />

                                </rich:column>

                            </rich:extendedDataTable>

                     

                        </h:form>

                    </h:body>

                    </html>

                     

                    The Controller:

                     

                    package de.handelshof.hin.archiv.web.beans.controller;

                     

                    import java.util.ArrayList;

                    import java.util.List;

                     

                    import javax.enterprise.context.ApplicationScoped;

                    import javax.inject.Named;

                     

                    @Named

                    @ApplicationScoped

                    public class MyController {

                     

                        public MyController() {

                            this.someList.add(new java.util.Date().toString());

                            this.someList.add(new java.util.Date().toString());

                        }

                     

                        private List<String>    someList = new ArrayList<String>();

                     

                        public List<String> getSomeList()

                        {

                            return this.someList;

                        }

                    }

                    • 7. Re: Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
                      Hardy Massen Novice

                      Michal Petrov wrote:

                       

                      The thing is <ui:include> is processed before the rendering starts (and @rendered is checked). See here.

                       

                      [...]

                       

                      What are you doing with those 5 snippets? Showing one at a time? You an use <c:choose> for that, or an ApplicationScoped bean that will hold the link to the page, so you end up with <ui:include src="#{bean.page}" />

                       

                      Yea, I have one switch (selectOneMenu) and depending on the selected menu-item I show one snippet at a time. All view-scoped and Ajax.

                       

                      <c:choose> seems to work for me.  But after reading the link you provided http://stackoverflow.com/a/11991895/1818198 I would have expected that it fails because of my view-Scoped beans:

                      "1. Use a view build time tag like <c:if> instead of <h:panelGroup>. This however puts implications into the #{managedBean}. It can't be view scoped and should do its job based on HTTP request parameters."

                       

                      I assume, there is no structural difference between <c:if> and <c:choose>, so if one doesn't work with view-scoped beans, the other one should not work either?

                       

                      Or does this have to do with the JSF-version, as described here: http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense and here https://java.net/jira/browse/JAVASERVERFACES-1492 ?

                      "...JSTL tags should be used carefully in Mojarra versions older than 2.1.18. Before this version, they don't work well together with view scoped beans when partial state saving is turned on (as by default). ..."

                       

                      We use JSF 2.1.19.

                      • 8. Re: RichFaces 4.3.5 - JSF 2.1.19 - two edt-tables, first sortOrder rules the second table
                        Michal Petrov Master

                        It might be the JSF version, I'll have to take a look on why the sortOrder breaks it. Still you might want to do some refactoring in your bean. Note that even if everything is ok, the getter will be called several times before the page is even rendered, it shouldn't return different data between the calls.