3 Replies Latest reply on Nov 7, 2006 10:28 PM by johnurban

    Sharing an Entity Between JSP's

    johnurban Newbie

      I have a jsf page that renders a table of data(DataModel). I can select a record by clicking on an edit link and do something logical inside a supporting SFSB, to that record.

      Now I want to click on that record an show a new JSF with detailed data from that record. Is the trick that I need to use:

      @Out in the supporting SFSB of the selectedObject, such that when the new JSF get rendered, the <h:outputText value="#{selectedObject.name}"/> is populated on the screen?

        • 1. Re: Sharing an Entity Between JSP's
          johnurban Newbie

          I should have posted the code:

          JSF with the call that needs to get me to the other screen:

           <h:column>
           <f:facet name="header">
           <h:outputText value="Print"/>
           </f:facet>
           <h:commandLink value="print" action="#{personFinder.print}">
           <f:param name="id" value="#{id}"/>
           </h:commandLink>
           </h:column>
          


          When I click on Print, I can see that I get the System.out in the server.log file:


          00:12:42,820 INFO [STDOUT] inside print..:531


          Here is the code for personFinder.print:

          ...
           @DataModelSelection
           @Out(required=false)
           private Person selectedPerson;
          ...
           @LoggedIn
           public String print() {
           System.out.println("inside print..:"+selectedPerson.getId());
           return "/uPrintLabel.jsp";
           }
          
          


          It does indeed get to my uPrintLabel.jsp. But my firstName and lastName don't have anything in them:

          <h:form>
          
           <table>
           <tr>
           <td><h:outputText value="#{selectedPerson.firstName}"/></td>
           </tr>
           <tr>
           <td><h:outputText value="#{selectedPerson.lastName}"/></td>
           </tr>
           </table>
          
          </h:form>
          
          


          This page contains nothing, even though selectedPerson has valid data inside of it. I need to display in this screen information about the selectedPerson.

          • 2. Re: Sharing an Entity Between JSP's
            Jens Weintraut Apprentice

            In my app I've a similar use-case. I think I had the same problem, too. My solution was to integrate the "detailed code" like your getFirstName() method in the component which manages the list and the selected item.

            I would prefer separated components, but I didn't find out how.

            • 3. Re: Sharing an Entity Between JSP's
              johnurban Newbie

              Are seperated components possible with seam? Old school way is the save the person object to the session or store it in a SFSB, then using the JSP's usebean, retrieve the data for display. How do you do this in Seam?