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

    order in parent-child page

    Rafael Jurado Newbie

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

       

      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
          Martin Kouba Master

          Hi,

          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
            Rafael Jurado Newbie

            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">
                       <framework:restrictions>
                                 <value>a.persona.id = #{personaHome.instance.id}</value>
                       </framework:restrictions>
             </framework:entity-query> 
            

             

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

             

            Thank you!