1 Reply Latest reply on Jun 22, 2007 5:08 AM by Pete Muir

    Newbie Question on JSF/Seam

    Raymond Eperen Newbie

      I just started with JSF Seam. I have created a working page that searches for a program for a client. The result is displayed in a datatable. The data displayed in the table comes from a List of simple POJOs bound to the table. One of the columns has a commandLink that is bound to a method on the backing bean. The idea is to somehow make available the client id (String) and program id (Integer) associated with the row selected, set them on a "real" client object and make that available to the page to which I will navigate (which can vary based on the page from which the user arrived). I'm sure there are a few ways to do this, but would like a best practice if there is one. This client object will be required to continue being passed around the system until someone navigates back to the search and selects a new client and program. I have figured out the basics of how to use @Name on the client class and use an @Out and @In on the backing bean properties, just not how to make the two properties in the List available to set on it.

        • 1. Re: Newbie Question on JSF/Seam
          Pete Muir Master

          Page parameters are the best way to do this:

          <s:link action="#{bean.select}" value="Select"/>
           <f:param name="clientId" value="#{foo.clientId}" />
           <f:param name="programId" value="#{foo.programId}" />
          </s:link>


          Where foo is the var in the datatable.

          <page view-id="/list.xhtml">
           <param name="clientId" value="#{client.id}" />
           <param name="clientId" value="#{program.id}" />


          @In Client client;
          @In Program program;
          
          public void select() {
          }


          You have injected the selected client and program (you need to make client and program available as contextual variables) - you can then put them in the session or whatever - watch out for LazyInitializationExceptions though. Read the SeamApplicationFramework chapter for more on this approach