5 Replies Latest reply on Jul 30, 2007 6:05 AM by Olivier Thierry

    Null value sent by s:link in dataTable

    Olivier Thierry Apprentice

      Hi,

      I have a problem when using dataTable tag, I think it's a newbie error but I can't find it ...

      What I want :
      - A list of employees
      - A link to go to a detailed page of the employee

      To do this, I have this JSF page :

      <f:view>
       <div class="section">
       <h:outputText value="Aucun employé" rendered="#{employes != null and employes.rowCount==0}"/>
       <h:dataTable id="employes" value="#{employes}" var="emp" rendered="#{employes.rowCount>0}">
       <h:column>
       <f:facet name="header">ID</f:facet>
       #{emp.id}
       </h:column>
       <h:column>
       <f:facet name="header">Nom</f:facet>
       #{emp.nom}
       </h:column>
       <h:column>
       <f:facet name="header">Prénom</f:facet>
       #{emp.prenom}
       </h:column>
       <h:column>
       <f:facet name="header">Action</f:facet>
       <s:link id="viewEmploye" value="Voir" action="#{employeCrud.selectEmploye(emp)}"/>
       </h:column>
       </h:dataTable>
      </div>
      </f:view>
      


      Here's the method selectEmploye in component employeCrud (CONVERSATION scope) :

      /**
       *
       */
       public void selectEmploye(fr.horoquartz.t4.core.employe.VOEmploye selectedEmploye)
       {
       if (selectedEmploye == null)
       {
       throw new IllegalArgumentException(
       "fr.horoquartz.t4.gui.employe.EmployeCrudActionBean.selectEmploye(fr.horoquartz.t4.core.employe.VOEmploye selectedEmploye) - 'selectedEmploye' can not be null");
       }
       try
       {
       this.handleSelectEmploye(selectedEmploye);
       }
       catch (Throwable th)
       {
       throw new fr.horoquartz.t4.gui.employe.EmployeCrudActionException(
       "Error performing 'fr.horoquartz.t4.gui.employe.EmployeCrudAction.selectEmploye(fr.horoquartz.t4.core.employe.VOEmploye selectedEmploye)' --> " + th,
       th);
       }
       }
      


      The list of employees works, but when I click on the action link to select an employee, the selectedEmploye parameter is null !

      What am I doing wrong ?

        • 1. Re: Null value sent by s:link in dataTable
          Brian Smith Apprentice

          Most likely, you need to place your table inside of an <h:form> so the value is actually submitted.

          • 2. Re: Null value sent by s:link in dataTable
            Christian Bauer Master

            s:link does NOT submit a form, it does NOT generate a JSF POSTback. Also, selectEmployee(emp) does not work that way, see the documentation re: EL enhancements in Seam. You want to look at the Hotel Booking example in Seam and see how this kind of thing is done.

            • 3. Re: Null value sent by s:link in dataTable
              Olivier Thierry Apprentice

              Well, that's what I did ... In the main.xhtml of Booking example (Seam 1.1.6), there is a <s:link> which works the same way I tried :

              <a:outputPanel id="searchResults">
               <div class="section">
               <h:outputText value="No Hotels Found" rendered="#{hotels != null and hotels.rowCount==0}"/>
               <h:dataTable id="hotels" value="#{hotels}" var="hot" rendered="#{hotels.rowCount>0}">
               <h:column>
               <f:facet name="header">Name</f:facet>
               #{hot.name}
               </h:column>
               <h:column>
               <f:facet name="header">Address</f:facet>
               #{hot.address}
               </h:column>
               <h:column>
               <f:facet name="header">City, State</f:facet>
               #{hot.city}, #{hot.state}, #{hot.country}
               </h:column>
               <h:column>
               <f:facet name="header">Zip</f:facet>
               #{hot.zip}
               </h:column>
               <h:column>
               <f:facet name="header">Action</f:facet>
               <s:link id="viewHotel" value="View Hotel" action="#{hotelBooking.selectHotel(hot)}"/>
               </h:column>
               </h:dataTable>
               <s:link value="More results" action="#{hotelSearch.nextPage}" rendered="#{hotelSearch.nextPageAvailable}"/>
               </div>
              </a:outputPanel>
              


              • 4. Re: Null value sent by s:link in dataTable
                Christian Bauer Master

                1. Use a newer Seam version, no idea if it works with the old one.

                2. "hotels" needs to be a @DataModel, see HotelSearchingAction.java

                • 5. Re: Null value sent by s:link in dataTable
                  Olivier Thierry Apprentice

                  I found where it comes from ...
                  My employeList seam component, which contains the employees list, was in CONVERSATION scope. So I think that the conversation was ended when running employeCrud component and of course it could not find the employee in the list ;)
                  I set my employeList component to SESSION scope and now it works better (other errors, but it goes further and this new error has nothing to see)