4 Replies Latest reply on Oct 22, 2005 5:34 AM by didi mann

    Nested Datatables

    didi mann Newbie

      Hi,

      I have the following requirement, as far as I can't make use of the @DataModel annotation (I think), because I want to render an initially unknown number of DataTables.

      Inject a Collection of ListDataModels into the Conversation Context and render them with a nested DataTable:


      <ui:define name="content">
      <div class="section">
      <h:form>
      <fieldset>
      <div class="section">
      <h:dataTable value="#{skills}" var="index">
      <h:column>
      <h:dataTable value="#{index}" var="skillIndex"
      rendered="#{not empty index}">
      <f:facet name="header">
      <f:verbatim>
      <div class="colheader">
      <h:outputText value="#{skilleditadmin.nexttyp}"/>
      </div>
      </f:verbatim>
      </f:facet>
      <h:column>
      <h:outputText value="#{skillIndex.skillname}"/>
      </h:column>
      <h:column>
      <h:commandButton type="submit" value="Delete" action="#{skilleditadmin.remove}"/>
      </h:column>
      </h:dataTable>
      </h:column>
      </h:dataTable>
      </div>
      </fieldset>
      </h:form>
      </div>

      <div class="section">
      <h:form>
      <fieldset>
      <div class="entry">
      <div class="label">
      <h:outputLabel for="name">Typ:</h:outputLabel></div>
      <div class="input">
      <h:inputText id="typ" value="#{skilleditadmin.tmptyp}">
      <!-- <f:selectItems value="#{typen}"/>-->
      </h:inputText>
      </div>
      </div>
      <div class="entry">
      <div class="label">
      <h:outputLabel for="name">Neuer Skill:</h:outputLabel></div>
      <div class="input">
      <h:inputText id="name" value="#{skilladmin.skillname}"/>
      <h:message for="name" />
      </div>
      </div>
      <div class="entry">
      <div class="label"> </div>
      <div class="input">
      <h:commandButton type="submit" value="Add" action="#{skilleditadmin.add}"/>
       
      <h:commandButton type="submit" value="Cancel" action="#{skilleditadmin.cancel}"/>
      </div>
      </div>
      </fieldset>
      </h:form>
      </div>
      </ui:define>


      The corresponding sections in the SessionBean, named skilleditadmin are as follows:


      ...
      @Out
      private Collection<ListDataModel> skills;
      ...
      public String remove()
      {
      log.info("in remove...");
      //getRowData and delete the item
      }



      Unfortunately the method "remove" is never invoked.
      When clicking a Remove-Button the page redisplays, without any data(which is displayed, when I renavigate to that page).
      (The data is displayed correct, as long as I do not click on the "delete Button".) Adding the data works also fine...

      Any ideas, or hints - please?

      Thanks
      hoetschmann



        • 1. Re: Nested Datatables
          didi mann Newbie

          The skills collection is a collection of ListDataModel objects...

          • 2. Re: Nested Datatables
            Louis Coetzee Apprentice

            Unfortunately no ideas, just a confirmation that I have the same type of behaviour where my method is never invoked (in a Stateless bean) when part of a dataList. Weird thing is that the method gets invoked when I remove it from my dataList (the Tomahawk version of dataTable).

            My xhtml:

            <h:form>
            <!-- invoke of #{serviceViewerAction.viewSelected} never occurs -->
            <t:dataList value="#{allServices}" var="currService" layout="simple"
             rowCountVar="rowCount" rowIndexVar="rowIndex"
             id="viewSelectedIDDataList">
             <h:commandLink action="#{serviceViewerAction.viewSelected}">
             <h:outputText value="#{currService.name}" />
             <t:updateActionListener property="#{serviceViewerAction.selectedServiceId}"
             value="#{currService.idAsInt}" />
             </h:commandLink>
             <h:outputText value="|====|" />
            </t:dataList>
            
            <hr />
            <!-- this one invokes the method -->
            <h:commandLink action="#{serviceViewerAction.viewSelected}"
             id="viewSelectedID">
             <h:outputText value="test" />
             <t:updateActionListener property="#{serviceViewerAction.selectedServiceId}"
             value="#{171}" />
             </h:commandLink>
            </h:form>
            


            "viewSelected" is defined in my Stateless bean interface and implemented in the Seam Bean named "serviceViewerAction".

            Regards

            Louis


            • 3. Re: Nested Datatables
              Louis Coetzee Apprentice

              Hi,

              the following helped me to sort out my problem
              http://www.mail-archive.com/users@myfaces.apache.org/msg09200.html

              Because I was using a Stateless bean my #{allServices} was null on the next request (e.g. when the user clicked the link). To fix I had to do the following in my bean:

               @In(required = false)
               @Out(required = false, scope = ScopeType.SESSION)
               private List<Service> allServices;
              


              i.e. force my collection to be Session scoped (not ideal but it works!).

              My thinking is that you have a similar problem in the sense that your Collection is Conversation scoped, and probably not available in the appropriate Phase of your JSF rendering.

              Regards

              Louis



              • 4. Re: Nested Datatables
                didi mann Newbie

                Great. Thanks for providing the link, Louis.
                Helped a lot - and it works fine now!

                Dirk