3 Replies Latest reply on Jun 1, 2006 9:36 AM by gmichalk

    Multiple datamodel in one bean

    gmichalk

      Hi,

      Here is my bean code

      @DataModel(value="searchResults")
      List searchResults;


      @DataModelSelection(value="qstChoisi")
      private Questionnaire qstChoisi;

      @DataModel(value="questionnairesChoisis")
      private List questionnairesChoisis;

      <h:dataTable value="#{searchResults}"
      var="msg"
      styleClass="dvdtable"
      headerClass="dvdtablehead"
      rowClasses="results"
      columnClasses="dvdtablecol">

      <h:column>
      <f:facet name="header">
      <h:outputText value="#{msgs.rechercheQuestionnaireSel}" />
      </f:facet>
      <h:selectBooleanCheckbox value="#{searchSelections[msg]}"/>
      </h:column>

      <h:column>
      <f:facet name="header">
      <h:outputText value="#{msgs.rechercheQuestionnaireReference}" />
      </f:facet>
      <s:link value="#{msg.id}" action="#{search.selectionneQuestionnaire}" />
      </h:column>

      <h:column>
      <f:facet name="header">
      <h:outputText value="#{msgs.rechercheQuestionnaireDescription}" />
      </f:facet>
      <h:outputText value="#{msg.commentaire}" />
      </h:column>

      <h:column>
      <f:facet name="header">
      <h:outputText value="#{msgs.rechercheQuestionnaireNiveau}" />
      </f:facet>
      <h:outputText value="#{msg.endroit.description}" />
      </h:column>

      </h:dataTable>

      Whith one DataModel, when I click on the id link, the action was correctly executed, but I cannot figure out how to make it work with a second datamodel.

      What is the meaning of the "value" parameter in the DataModelSelection annotaion ? I went to seam documentation, but it was not very helpful

      Kind regards,
      Gerd

        • 1. Re: Multiple datamodel in one bean
          pmuir

          It 'attaches' the DataModelSelection(Index) to the correct DataModel. i.e.

          @DataModel
          List searchResults;
          
          @DataModelSelection("searchResults")
          Object searchResult;
          
          @DataModel
          private List questionnairesChoisis;
          
          @DataModelSelection("questionnairesChoisi")
          private Questionnaire qstChoisi;
          
          


          Note that value is the default attribute for an annotation so you don't need value=

          • 2. Re: Multiple datamodel in one bean
            iradix

            The value attribute of the @DataModel is the name that it is outjected as. Each @DataModel should have a @DataModelSelection with the same value which will recieve the selected row. If there is only one DataModel/Selection then the value attribute is not necessary for obvious reasons.

            Try:

            @DataModelSelection(value="questionnairesChoisis")
            private Questionnaire qstChoisi;

            @DataModel(value="questionnairesChoisis")
            private List questionnairesChoisis;

            • 3. Re: Multiple datamodel in one bean
              gmichalk

              Thanks, it works now

              Kind regards,
              Gerd