1 Reply Latest reply on Sep 29, 2008 8:21 AM by Ilya Shaikovsky

    scrollableDataTable selection only works with session scope

    Josue Martinez Buenrrostro Newbie

      Hello everybody:

      I have a scrollableDataTable and y need to use multiple selection rows but that works only if my session bean hava a "session" scope if i use "request" scope, getSelection().getKeys() is empty.

      I'm using:

      Spring Framework 2.5.5 with annotations, richfaces 3.2.2.GA and mojarra_1.2_09 (with facelets)

      The scrollableDataTable is:

      <rich:scrollableDataTable rowKeyVar="rkv" frozenColCount="5" height="400px" width="850px" id="bienes" rows="0" columnClasses="col"
      value="#{listarBienesBean.bienesPorSubasta}"
      var="bien" sortMode="single"
      binding="#{listarBienesBean.tabla}"
      sortOrder="#{listarBienesBean.orden}"
      selection="#{listarBienesBean.seleccion}">


      And the bean is defined as:

      @Controller(value = "listarBienesBean")
      @Scope("session")
      public class ListarBienesBean {

      ...
      private SimpleSelection seleccion = new SimpleSelection();
      private UIScrollableDataTable tabla;
      private SortOrder orden = new SortOrder();
      private List bienesSeleccionados = new ArrayList();
      ...

      public SimpleSelection getSeleccion() {
      return seleccion;
      }

      public void setSeleccion(SimpleSelection seleccion) {
      this.seleccion = seleccion;
      }

      public void consultarBienesSeleccionados() throws HumanTechSolutionsWebException {
      try {
      getBienesSeleccionados().clear();
      if (getSeleccion().isSelectAll()) {
      getBienesSeleccionados().addAll(bienesPorSubasta);
      } else {
      //Iterator gets NOT empty ONLY with SESSION SCOPE BEAN
      //Wath's up?
      Iterator iterator = getSeleccion().getKeys();
      while (iterator.hasNext()) {
      Object key = iterator.next();
      tabla.setRowKey(key);
      if (tabla.isRowAvailable()) {
      getBienesSeleccionados().add((Bien) tabla.getRowData());
      }
      }
      }
      } catch (Exception e) {
      throw new HumanTechSolutionsWebException("Error al ejecutar ListarBienesBean.listarBienes()", e);
      }
      }
      ...
      }


      getSeleccion() and setSeleccion() works Ok but consultarBienesSeleccionados() only works Ok when scope for bean is "session". If i change the scope to "request" getSeleccion().getKeys() return empty.

      The problem is i need a "request" scope bean for my business.

      What is wrong with my Bean?

      Thanks in advance.

      Regards from Mexico.