2 Replies Latest reply on Jul 26, 2009 1:04 AM by joblini

    Propagating request parameters in PAGE context

    vitorsouzabr

      Hello all,


      I'm working on a CRUD and so far I have defined the scope of the Action bean at the SESSION, but I was thinking it would be nice if the scope was PAGE, so the user wouldn't have a problem opening two tabs in the same CRUD.


      Since I have two views: list.xhtml and form.xhtml, with the SESSION scope I didn't have any problem, but with the PAGE scope, once I change from one page to another, a new Action bean is created.


      So, if I click on the Update button, I'm supposed to go from the list to the form and view the current data about the object (and possibly change it). But the form comes empty, because first the object is selected, then a new blank Action bean is created, and by the time the new view is rendered, the property of the selected object (in the newly-created action bean) is empty.


      Section 6.4 (Propagating request parameters) of Seam's reference mentions Propagation of page parameters is especially useful if you want to build multi-layer master-detail CRUD pages. So first I tried this:


      <page view-id="/crud/form.xhtml" action="#{crudAction.create}">
           <param name="crudSelectedEntity" />
      </page>



      But that throws an exception saying my domain class can't be converted to String. So I'm concluding it doesn't work for complex objects. What I could do is this:


      <page view-id="/crud/form.xhtml" action="#{crudAction.create}">
           <param name="entityId" value="#{crudSelectedEntity.id}" />
           <action execute="#{crudAction.restoreEntity}" />
      </page>



      And have the restoreEntity() method retrieve that entity from the database again.


      From the old times of WebWork/Struts2, I remember the chain result, which would set in the following Action object all the properties from the previous action object, given the propert get/set methods were supplied.


      So my question is, is there a simpler way of achieving the chain result from one PAGE-scoped Action object to another and propagate a whole domain entity to be used in the next page?


      Thanks in advance for any pointers,


      Vítor Souza