I don't know if it's the best solution, but in a past project I did it
like this:
I had one request-scoped bean per screen, and I had a
"setSelectedObject(Object object)" method on each of those beans.
The original page was responsible for calling "setSelectedObject()" on
the target bean page. If it passed a null object, the bean created a
new one. Otherwise, it stored the object as appropriate.
The caller could either set the value programmically, or it could set
it on the UICommand:
<h:commandButton ...>
<f:setPropertyActionListener
target="#{targetPageBean.selectedObject}"
value="#{currentPageBean.objectToPass}"/>
</h:commandButton>
On 7/21/08, Guy Bashan <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi,
>
>
>
> You will to excuse me for this question, I have always worked with request
> scope beans:
>
> I have a screen in which details are being edited. Now, I have to add a
> button near one of the drop downs that will take me to a new screen,
> allowing me to create a new object and get back to the previous screen. Of
> course I will have to save the data in the first screen when moving to the
> second one and when returning data should be restored.
>
> So I thought setting my entity bean (hibernate pojo) as a session bean,
> allowing me to store the state when moving from one screen to another. My
> question is: what mechanism can I use in order to initialize the entity
> bean. When going to the "create new object" screen I will want to "remember"
> the data, but when coming to the screen from some other place I will want
> the object to be either initialize, or to contain the data of a loaded
> object. I also don't want to start calculating from which screen or link I
> am coming to this screen in order to decide in which cases I have to
> initialize the object and in which not.
>
>
>
> Is there a neat way of doing it?
>
> Btw, I can't use Seam or some framework currently on this project.
>
>
>
> Thanks,
>
> Guy.