0 Replies Latest reply on Mar 24, 2011 5:35 PM by igorstephano

    Problems with selectBooleanCheckbox on a rich:dataTable that uses SerializableDataModel

    igorstephano
      Hi,
      Im using JSF RichFaces with JBOSS Seam.
      Ive got a rich:dataTable inside a ruch:modalPanel. This dataTable has 3 columns the first with code,
      the second with name and the third with a h:selectBooleanCheckbox.
      This dataTable is loaded with a SerializableDataModel and I use a rich:datascroller for move through the pages.
      I have to save all the selected rows in a list of objects.
      I save it when I check the selectBooleanCheckbox, I use this code:

                                    <h:selectBooleanCheckbox value="#{unidad.seleccionado}">
                                         <a4j:support event="onchange"
                                              action="#{proyectoNuevoAction.agregarEntidadParticipante(unidad)}"
                                              ajaxSingle="true" />

                                    </h:selectBooleanCheckbox>
                                    
      When I scroll to the 2 page for example and I check
      one of the 10 rows the element unidad has the value of the row and I enter to the function
      proyectoNuevoAction.agregarEntidadParticipante(unidad) so I can save the row,
      but when I try to check a second row in the same 2 page the element now is null and don't enter
      to the function.
      I have figured out that everytime that I do a request on this page the function of the
      action class that load the elements is called.

      @Override
           protected Collection<AdmEntidad> loadData(int firstResult,
                     int numberOfRows, String orderField, String orderDirection) {
                     
                     }
                     
      The first time it tha variable firsResult has 20(cause we are on the 2 page), but
      the next time I press another selectBooleanCheckbox it has the value 0.
      Now I don't know how to do to if Im in the second page and if I press the selectBooleanCheckbox
      the variable firstResult of the load function has the value of 20 instead of 0.


      This is my action

      @Name("entidadPaginacion")
      @Scope(ScopeType.CONVERSATION)
      public class EntidadPaginacion extends Paginacion<AdmEntidad> {

           private static final long serialVersionUID = 1L;

           @Override
           public Serializable getId(AdmEntidad entity) {
                return entity.getCodigoEntidad();
           }

           @Override
           protected int countRecords() {
                int totalUnidadesEjecutoras = 0;
                totalUnidadesEjecutoras = BOLocatorController.getAdmEntidadBO().countAll()
                return totalUnidadesEjecutoras;
           }

           @Override
           protected Collection<AdmEntidad> loadData(int firstResult,
                     int numberOfRows, String orderField, String orderDirection) {

                Collection<AdmEntidad> unidades = new ArrayList<AdmEntidad>();
                
                                    unidadesEjecutoras = BOLocatorController
                                              .getAdmEntidadBO()
                                              .searchAll();
                               
                return unidades;
           }
           
           This is my dataTable
           
           <rich:dataTable id="tablaUnidadEjecutora" value="#{entidadPaginacion}"
                      var="unidad"
                     rowClasses="fila-par, fila-impar" rows="10">
                     <f:facet name="header">
                          <h:outputText
                               value="#{messages['sipp.modal.buscarunidad.tabla.titulo']}" />
                     </f:facet>

                     <rich:column sortBy="#{unidad.nemonicoEntidad}">
                          <f:facet name="header">
                               <h:outputText
                                    value="#{messages['sipp.modal.buscarunidad.tabla.columna.nemonico']}" />
                          </f:facet>
                          <h:outputText value="#{unidad.nemonicoEntidad}" />
                     </rich:column>

                     <rich:column sortBy="#{unidad.razonSocial}">
                          <f:facet name="header">
                               <h:outputText
                                    value="#{messages['sipp.modal.buscarunidad.tabla.columna.nombre']}" />
                          </f:facet>
                          <h:outputText value="#{unidad.razonSocial}" />
                     </rich:column>

                     <rich:column width="100" styleClass="centered">
                          <f:facet name="header">
                               <h:outputText value="#{messages['sipp.tabla.columna.opciones']}" />
                          </f:facet>
                          <h:panelGroup>
                               <h:selectBooleanCheckbox value="#{unidad.seleccionado}">
                                         <a4j:support event="onchange"
                                              action="#{proyectoNuevoAction.agregarEntidadParticipante(unidad)}"
                                              ajaxSingle="true" />
                                    </h:selectBooleanCheckbox>
                          </h:panelGroup>
                     </rich:column>
                     <f:facet name="footer">
                          <h:panelGrid columns="4">
                               <a4j:commandButton value="#{messages['sipp.boton.aceptar']}"
                                    onclick="Richfaces.hideModalPanel('listaMultiEjecutoras'); "
                                    action="#{proyectoNuevoAction.agregarEntidadesParticipantes}"
                                    ajaxSingle="true"
                                    reRender="entidadesParticipantesForm, tablaUnidadEjecutora" />
                               <a4j:commandButton value="#{messages['sipp.boton.cerrar']}"
                                    onclick="Richfaces.hideModalPanel('listaMultiEjecutoras'); "
                                    action="#{proyectoNuevoAction.seleccionarEntidadesParticipantes}"
                                    ajaxSingle="true"
                                    reRender="entidadesParticipantesForm, tablaUnidadEjecutora" />
                               <rich:datascroller  />
                          </h:panelGrid>
                     </f:facet>
                </rich:dataTable>



      Hope someone can help me.

      Thanks in advance