5 Replies Latest reply on May 4, 2007 11:51 AM by delphi'sghost

    Really simple, please advice (passing h:dataTable to event)

    viniciuscarvalho

      Hi there! I have a really simple question, can not find the answer :(

      I'm trying to start a conversation on a second page after the user clicks on
      a link in a view:

      <h:dataTable value="#{customers}" var="c">
      
      ....
      
      <s:link id="startRentProcess" value="Start Rental" action="#{rentalService.start(c)}"/>
      
      My RentalService:
      
      @Name("rentalService")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class RentalBean implements RentalService {
      
      @In(required=false) @Out
       private Customer customer;
      @Begin
       public void start(Customer c) {
       rental = new Rental();
       customer = c;
       rental.setCustomer(c);
       }
      


      The previous page is backed by a SLSB. When I get at the start, the Customer is null, not the one I've selected through the <s:link>

      What am I missing? Do I need a @DataModelSelection?

      Best regards





        • 1. Re: Really simple, please advice (passing h:dataTable to eve
          stu2

           

          "viniciuscarvalho" wrote:
          Hi there! I have a really simple question, can not find the answer :(

          I'm trying to start a conversation on a second page after the user clicks on
          a link in a view:

          <h:dataTable value="#{customers}" var="c">
          
          ....
          
          <s:link id="startRentProcess" value="Start Rental" action="#{rentalService.start(c)}"/>
          
          My RentalService:
          
          @Name("rentalService")
          @Stateful
          @Scope(ScopeType.SESSION)
          public class RentalBean implements RentalService {
          
          @In(required=false) @Out
           private Customer customer;
          @Begin
           public void start(Customer c) {
           rental = new Rental();
           customer = c;
           rental.setCustomer(c);
           }
          


          The previous page is backed by a SLSB. When I get at the start, the Customer is null, not the one I've selected through the <s:link>

          What am I missing? Do I need a @DataModelSelection?

          Best regards





          The easiest way would be to use a @RequestParameter variable in your SFSB, like this:

          @RequestParameter String customerId;


          and

          <s:link id="startRentProcess" value="Start Rental" action="#{rentalService.start()}">
           <f:param name="customerId" value="#{customer.id}"/>
          </s:link>


          Seam will set the variable when the link is clicked, and you can retrieve the customer at that point.

          • 2. Re: Really simple, please advice (passing h:dataTable to eve
            viniciuscarvalho

            Thanks, now, just to understand, why my idea did not work? I'm using the booking example as reference and its pretty much the same code.

            Could not find why
            hotelSearch.selectHotel(hot) works and
            rentalService.start(c) does not... :(

            Any ideas?

            • 3. Re: Really simple, please advice (passing h:dataTable to eve
              pmuir

              IIRC you need a h:commandLink, not an s:link

              • 4. Re: Really simple, please advice (passing h:dataTable to eve
                viniciuscarvalho

                I'll give a try, but why on the examples (booking) we have this:

                <h:column>
                 <f:facet name="header">Action</f:facet>
                 <s:link id="viewHotel" value="View Hotel" action="#{hotelBooking.selectHotel(hot)}"/>
                 </h:column>
                


                and it works? And on my version (as I stated before, I'm using the booking as reference, and almost everythng is the same)
                it does not work?

                Regards

                • 5. Re: Really simple, please advice (passing h:dataTable to eve
                  delphi'sghost

                  Can you show where the customers list is coming from, and what your syntax for the datatable tag is?