9 Replies Latest reply on Sep 1, 2008 10:05 AM by Rolf Kulemann

    a4j re render breaks t:commandSortHeader

    Rolf Kulemann Newbie

      If I re render a div containing a t:commandSortHeader, I can not execute the sorting by clicking on the header text anymore. I get the following java script error:

      Error: form is undefined
      Source: http://localhost:8080/neopsa/a4j_3_2_0.SR1-SNAPSHOTorg.ajax4jsf.javascript.AjaxScript.jsf
      row: 115

      If I reRender "opportunities" (the datatable) itself, sorting keeps working.

      page code (abstract):

      ...
      <a4j:commandButton reRender="data"..../>

      <t:div id="data">
      <a4j:form>
      <t:dataTable id="opportunities">
      <h:column>
      <f:facet name="header">
      <t:commandSortHeader columnName="customer.name" arrow="true"
      immediate="false">
      <h:outputText value="#{modelBundle.prospect}" />
      </t:commandSortHeader>
      </f:facet>
      <h:outputText value="#{document.customer.name}" />
      </h:column>
      </t:dataTable>
      </a4j:form>
      </t:div>

      ...

        • 1. Re: a4j re render breaks t:commandSortHeader
          Ilya Shaikovsky Master

          your button is outside the form. why you expect that it should work?

          • 2. Re: a4j re render breaks t:commandSortHeader
            Rolf Kulemann Newbie

             

            "ilya_shaikovsky" wrote:
            your button is outside the form. why you expect that it should work?


            No, it is inside a form. Sorry for that. The problem is not that no re rendering happens. It happens, but breaks sorting of the datatable header.

            • 3. Re: a4j re render breaks t:commandSortHeader
              Ilya Shaikovsky Master

              sorry but could you update your version to latest 3.2.2 CR2..?

              • 4. Re: a4j re render breaks t:commandSortHeader
                Rolf Kulemann Newbie

                 

                "ilya_shaikovsky" wrote:
                sorry but could you update your version to latest 3.2.2 CR2..?


                That was the first thing I tried, but no changes.

                To make things clearer, here is the code to isolate the problem.

                <html

                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:t="http://myfaces.apache.org/tomahawk"
                xmlns:p="http://www.neo-partners.com/psa/facelets"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j"
                >


                <a4j:form>
                <a4j:commandButton reRender="data" value="Refresh"/>
                </a4j:form>

                <t:div id="data">
                <a4j:form>
                <t:dataTable id="persons" value="#{personBean.testPersons}"
                var="person" styleClass="datatable"
                columnClasses=",,,,,currencyCell,,,,,currencyCell,currencyCell"
                headerClass="datatable-header"
                rowClasses="datatable-row-even, datatable-row-odd"
                sortColumn="#{personBean.sortPropertyName}"
                sortAscending="#{personBean.sortAscending}"
                preserveSort="false" renderedIfEmpty="false"
                forceIdIndexFormula="#{document.uid}">

                <h:column>
                <f:facet name="header">
                <t:commandSortHeader columnName="name" arrow="true"
                immediate="false">
                <h:outputText value="FName" />
                </t:commandSortHeader>
                </f:facet>
                <h:outputText value="#{person.firstName}" />
                </h:column>
                </t:dataTable>
                </a4j:form>
                </t:div>





                Unfortunately I have lots of pages using t:commandSortHeader. The problem is 100% reproducable.

                • 5. Re: a4j re render breaks t:commandSortHeader
                  Rolf Kulemann Newbie

                  FYI: After a page reload, the sorting works again.

                  • 6. Re: a4j re render breaks t:commandSortHeader
                    Rolf Kulemann Newbie

                    I have changed the isolation code a bit. I have now 3 a4j:button s reRendering different parent levels of the datatable. Only the button, which rerenders the datatable direct, keeps the commandSortHeader working.

                    <html
                    
                    xmlns="http://www.w3.org/1999/xhtml"
                     xmlns:ui="http://java.sun.com/jsf/facelets"
                     xmlns:h="http://java.sun.com/jsf/html"
                     xmlns:f="http://java.sun.com/jsf/core"
                     xmlns:t="http://myfaces.apache.org/tomahawk"
                     xmlns:p="http://www.neo-partners.com/psa/facelets"
                     xmlns:rich="http://richfaces.org/rich"
                     xmlns:a4j="http://richfaces.org/a4j"
                     >
                    
                    <body>
                     <a4j:form>
                     <!-- Breaks commandSortHeader -->
                     <a4j:commandButton reRender="data" value="Refresh Data"/>
                     <!-- Breaks commandSortHeader -->
                     <a4j:commandButton reRender="dataForm" value="Refresh Data Form"/>
                     <!-- DOES NOT BREAK commandSortHeader -->
                     <a4j:commandButton reRender="persons" value="Refresh Persons"/>
                     </a4j:form>
                    
                     <t:div id="data">
                     <a4j:form id="dataForm">
                     <t:dataTable id="persons" value="#{personBean.testPersons}"
                     var="person"
                     sortColumn="#{personBean.sortPropertyName}"
                     sortAscending="#{personBean.sortAscending}"
                     preserveSort="false"
                     renderedIfEmpty="false">
                    
                     <t:column>
                     <f:facet name="header">
                     <t:commandSortHeader columnName="name" arrow="true"
                     immediate="false">
                     <t:outputText value="FName" />
                     </t:commandSortHeader>
                     </f:facet>
                     <t:outputText value="#{person.firstName}" />
                     </t:column>
                     </t:dataTable>
                     </a4j:form>
                     </t:div>
                    </body>
                    
                    
                    </html>
                    


                    • 7. Re: a4j re render breaks t:commandSortHeader
                      Rolf Kulemann Newbie

                      FYI: I get the same java script error for all h:commandLink s inside the persons form. Bute here I can work around it by using a4j:commandLink instead of h:commandLink. In case of the t:commandSortHeader, I have no possibility to influence the link rendering.

                      • 8. Re: a4j re render breaks t:commandSortHeader
                        Ilya Shaikovsky Master

                        So seems you need update whole dataTable while using tomahawk in order all nesessary scripts to be included.

                        B.t.w. you could use Rich Faces dataTable and its sorting capabilities.

                        • 9. Re: a4j re render breaks t:commandSortHeader
                          Rolf Kulemann Newbie

                           

                          "ilya_shaikovsky" wrote:
                          So seems you need update whole dataTable while using tomahawk in order all nesessary scripts to be included.

                          B.t.w. you could use Rich Faces dataTable and its sorting capabilities.


                          I thought when re rerendering the parent container of the t:datatable everything down under is re rendered, isn't it?

                          Unfortunately atm I can not use rich:datatable for some let's say political reason.

                          So, this is not a bug of richfaces? Or at least a missing feature?