3 Replies Latest reply on Jan 5, 2009 5:34 PM by matthieugd

    s:link inside datatable and parameter

    matthieugd

      .Hello,


      I try to add an s:link inside a richfaces datatable which opens a new window (or new tab) by calling a action with an object as parameter


      Here's my datatable :




      <rich:column headerClass="caption">
                       <f:facet name="header"></f:facet>
                       <h:commandLink id="lienModifierCompte" target="_blank" 
      rendered="#{dossier.compteExistant}" 
      action="#{consultationCompte.consulterCompte(dossier)}">modifier</h:commandLink>
      
                       <s:link id="lienCréerCompte" 
      rendered="#{!dossier.compteExistant}" 
      action="#{creationCompte.initCreationCompte(dossier)}" value="créer"/>                                
                  </rich:column>




      My search bean as the list as DataModel :


      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("recherchePersonne")
      public class RecherchePersonneBean implements RecherchePersonne {
      
           @EJB
           private DifSF service;
           
           /**
            * Collection résultat
            */
           @DataModel
           private List<Dossier> dossierResultats;
      (...)




      And the bean called by the s:link :



      @Begin
      public void initCreationCompte(Dossier dossier) {
        currentDossierDIF = dossier;          
      }



      The h:commandlink works but the dossier parameter of the s:link is always null. I've seen the booking example and it seems to be the same as my requirement but I can't find my problem. When I execute the booking sample one difference is the href generated, the dataModelSelection argument is missing in the URL generated in my datatable but I don't see where does it come, the bean HotelSearchingAction defined only a DataModel (the search result list) but no dataselectionmodel.


      http://localhost:8080/seam-booking/main.seam?actionMethod=main.xhtml%3A
      hotelBooking.selectHotel%28hot%29&cid=12&dataModelSelection=hot%3Ahotels%5B4%5D



      and mine is :



      http://localhost:8080/dif/resultatRecherche.seam?actionMethod=resultatRecherche.xhtml%3
      AcreationCompte.initCreationCompte%28dossier%29&cid=2
       



      The Dossier class is a POJO from a jar library, it's not a component defined.


      I've seen this thread (http://seamframework.org/Community/ConversationLifecycleQuestion ) with the same problem.




        • 1. Re: s:link inside datatable and parameter
          matthieugd

          I found my problem in the EL expression of the rich:datable value I use :



          <rich:dataTable id="resultats" value="#{myBean.dossierResultats}" var="dossier" />




          and not :




          <rich:dataTable id="resultats" value="#{dossierResultats}" var="dossier" />


          which is working



          I look at the source of the s:link component and the getParentUIData returned a HtmlDataTable where the getValue() return null and not the collection.


          Matthieu

          • 2. Re: s:link inside datatable and parameter
            zergspirit

            Your parameter inside an action call of a s:link can't work because of how it's generated jsf cycle wise, so you should use a h:commandLink there.


            Anyway, since apparently you want to perform some basic CRUD action here, I'd strongly advise you to use EntityHome, which avoid a lot of conversation issues and are very easy to use. See the docs of the Wiki knowledge base to kow more about it.

            • 3. Re: s:link inside datatable and parameter
              matthieugd

              Adrien Orsier wrote on Jan 05, 2009 16:18:
              Your parameter inside an action call of a s:link can't work because of how it's generated jsf cycle wise, so you should use a h:commandLink there.


              I don't unterstand your answer, my s:link works indeed with the correct EL expression ie value="#{dossierResultats}" instead of value="#{myBean.dossierResultats}"


              Have you look to the booking example ? It uses a s:link inside a datatable.