1 Reply Latest reply on Oct 22, 2010 4:47 PM by csreeraman

    Factory values in a view

    csreeraman
      Hello - Seam Newbie here.

      I have an application where I show a list of values that the user can select (using checkboxes). The values are static data from the database. I have also created a class that holds the values from the database as well as a boolean to indicate if it has been selected.

      I am using an application scoped factory to get the values from the database (since these values are frequently used) and am using these in a view.

      My question is :

      Is there a way to capture the values from the view to a backing bean and process the values - ie., on submit - i'd like to see which types were selected etc.

      Thanks in advance.

      Chandra Sreeraman


      Code Below:

      E.G:
      table - clienttype - values - {[id=1, type=MM], [id=2, type=BB]}

      ==== Model
      @Name ("clientTypesModel")
      public class ClientTypeModel {

              private Clienttype clientType;
              private Boolean selected;
                     :
                     :

      == Factory
      @Name("clientTypeFactory")
      @Scope(ScopeType.APPLICATION)
      public class ClientTypeFactoryManager implements Serializable {

          @In
          private EntityManager entityManager;

          @Factory(value = "clientTypes")
          public void findContingencies() {
              List<Clienttype> clientTypesList = entityManager.createQuery("select clienttype from Clienttype clienttype ")
                      .getResultList();

              if (this.clientTypes == null) {
                  this.clientTypes = new ArrayList<ClientTypeModel>();
              }
              for (Clienttype ct : clientTypesList) {
                  ClientTypeModel ctm = new ClientTypeModel(ct, false);
                  this.clientTypes.add(ctm);
              }

          }
                    :
                    :
                    :

      ========

      view

                              <rich:panel>
                                      <f:facet name="header">
                                              <h:outputLabel value="Participant Type" />
                                      </f:facet>
                                      <rich:dataTable
                                              var="participantType"
                                              value="#{auditManager.clientTypesList}"
                                              style="vertical-align:top">
                                              <rich:column>

                                                      <h:selectBooleanCheckbox value="#{participantType.selected}" />
                                              </rich:column>

                                              <rich:column>
                                                      <h:outputText value="#{participantType.clientType.name}" />
                                              </rich:column>

                                      </rich:dataTable>
                              </rich:panel>


      -----------------------