1 Reply Latest reply on Sep 28, 2011 3:15 PM by Ismael Gimenez

    extendedDataTable migration to RF4 (a4j:support and f:setPropertyActionListener)

    Ismael Gimenez Newbie

      Hello everyone, I am migrating my RichFaces 3.3.1, JSF 1.2 app to Richfaces 4 with JSF2. Everything was find until migrating a extendedDataTable.

      Its seems that a4j:support is no longer supported (bad joke ) on Richfaces 4. I read somewhere that using a4j:ajax or a4j:jsFuntion did the trick, however im not able to make it work.

       

      The idea is to when the user clicks on a item of the table the id of that element (i[0]) is saved on the bean (bean.idEntidad) and aftewards the bean.onSelectEntidadID method is executed. This method queries the database for the object and does some other things.

       

      (Note: the list is on a template using facelets)

       

      Below is the code of the xhtml

       

      <ui:composition>

              <a4j:region>

                  <rich:extendedDataTable rowClasses="rowPar,rowImpar" rows="20" width="100%" align="center" id="listadoTabla" value="#{listado.model}" var="i" onRowMouseOver="$(this).addClassName('rowSel')"  onRowMouseOut="$(this).removeClassName('rowSel')">

                      <a4j:support eventsQueue="listadoQueue" event="onRowClick" reRender="#{bean.reRenders}" action="#{bean.onSeleccion}">

                          <f:setPropertyActionListener value="#{i[0]}" target="#{bean.idEntidad}" />

                      </a4j:support>

                      <ui:insert name="columnas" />

                  </rich:extendedDataTable>       

              </a4j:region>

          </ui:composition>

       

      Below is part of the code in the Bean

       

           public String onSeleccion() {

              onSeleccionEntidadId(idSeleccionado);

              return null;

          }

         

          public abstract void onSeleccionEntidadId(Long id);

       

      the onSeleccionEntidadId is overriden in the specific bean.

       

      I want to migrate this to richfaces 4! Thanks in advance for any answer!

        • 1. Re: extendedDataTable migration to RF4 (a4j:support and f:setPropertyActionListener)
          Ismael Gimenez Newbie

          Nevermind.. it was quite easy. For anyone with the same problem (i doubt it) i leave my solution. Trivial stuff.

           

          in the page:

           

          <rich:extendedDataTable id="table" style="width:300px;" rows="20"

                  selection="#{bean.

          seleccionados}" var="item" value="#{listado}" selectionMode="single"
                   rowClasses="odd-row, even-row" styleClass="stable">
                  <a4j:ajax execute="@form"
                          event="selectionchange"
                          listener="#{bean.selectionListener}" render="@all" />
          ...

           

          in the Managed Bean:

           

          public void selectionListener(AjaxBehaviorEvent event) {
                  UIExtendedDataTable dataTable = (UIExtendedDataTable) event.getComponent();
                  Object originalKey = dataTable.getRowKey();
                   for (Object selectionKey : entidad) {
                      dataTable.setRowKey(selectionKey);
                      if (dataTable.isRowAvailable()) {
                          idSeleccionado = ((Entidad)dataTable.getRowData()).getId();
                              onSeleccionEntidadId(idSeleccionado);
                      }
                  }
                  dataTable.setRowKey(originalKey);
              }

           

          Cheers!