2 Replies Latest reply on Nov 14, 2012 7:52 AM by i92jurir

    order in parent-child page


      Hi, I have a problem with a parent-child page.



      <!-- Parent -->
      <h:panelGrid columns="2">
            <s:decorate id="dni" template="layout/display.xhtml">
                 <ui:define name="label">DNI</ui:define>
                 <h:outputText value="#{personaHome.instance.dni}" />
           <s:decorate id="nombre" template="layout/display.xhtml">
                 <ui:define name="label">Nombre</ui:define>
                 <h:outputText value="#{personaHome.instance.nombre}" />
      <!-- Childs:   1:N asistencias field -->
      <rich:dataTable var="_asistencias" value="#{personaHome.instance.asistencias}" rendered="#{not empty personaHome.instance.asistencias}" id="asistenciasTable" rows="10">
                <f:facet name="header">Fecha</f:facet>
                <h:outputText value="#{_asistencias.fecha}" >
                     <s:convertDateTime type="date" dateStyle="short" pattern="dd MMM yyyy" />
           ... more columns


      The problem is I need child ordered by fecha field when page is shown. I have tried several things but anything doesn´t work. Can someone help me? This is the last detail to finish my app! Please help.


      Thanks in advance.

        • 1. Re: order in parent-child page


          either try to use RichFaces sorting support (see also RF3 developer guide and RF3 live demo) or, might be a better solution, sort data when loading from persistence layer (e.g. db) -> this of course depends on your  personaHome and entities implementations (e.g. place javax.persistence.OrderBy).

          • 2. Re: order in parent-child page

            Hi Martin,


            I have tried your second aproach. Now I load the child this way:


            <rich:dataTable var="_asistencias" value="#{misAsistencias}" ....>


            In components I have added a factory component:


            <framework:entity-query ejbql="select a from Asistencia a join fetch a.persona pa" name="misAsistenciasQuery" order="a.fecha desc" scope="conversation">
                                 <value>a.persona.id = #{personaHome.instance.id}</value>


            The order attribute works fine when retrieves the data from the database.


            Thank you!