Hi Yannick,

t:saveState performs two actions:

At the very end of the rendering phase, it looks up the object specified by its value attribute and serializes it.

During the "restore view" phase, it deserializes its associated object, then evaluates its "value" attribute and assigns the recreated object to it.

I don't understand your statements about having "to modify the saveState component". You modify the object that the saveState component points to, not the saveState component itself. And in general that's trivial.


However from your description below, it looks like you're just trying to do a basic master/detail screen. In this case, you don't need saveState at all. Sorry if the reason why you want to use saveState here was given at the start of this thread; I haven't got that easily available. However for basic master/detail stuff, there is an example in the "examples" directory of the MyFaces download that you may wish to look at; it doesn't need saveState at all.

Regards,

Simon

PS: aargh, I hate top-posting!

Yannick Le Teigner wrote:
Simon,

The problem I face with the saveState component, is that when I place it on the master (1st) page, it is, as expected, initialized with no value (because the user has yet to click on a row in the datatable to edit a user/item.) Once the user click on a row, the detail page is displayed. But the BackingBean is reloaded from the saveState component, and is set as empty (as it was on the master page) -- and not initialized with the data from the row the user has clicked on. What I would need is somehow to modify the saveState component before the detail page is displayed so that I can modify the backingbean inside and put one correctly initialized (corresponding to the row the user has clicked on).

This seems like a basic app, but I cannot get around it without using session scoped bean. I would be very welcome if anyone could show me some code with request scoped beans achieving the same results.

Thanks!

> <t:saveState> is the correct tag to use when you want to avoid session-scoped managed
 > beans.
 >
> I don't know why you have that command-link code; nothing like this is necessary to use > t:saveState. If you wish to preserve the state of an entire managed bean, then do:
 >
 >Master page:
 >  <t:saveState value="#{myBackingBean}"/>
 >
 > Detail page:
 >  <t:saveState value="#{myBackingBean}"/>
 >
> On first visit to the master page, there is no saved state to restore, so a default instance > of that bean is created. When the page is serialized after rendering, the bean's state is
 > stored.
 >
> When either the master or detail page is visited thereafter, the saved object is recreated > from the saved state, and #{myBackingBean} is set to be a reference to the restored
 > object.
 >
 > You can also save just specific fields of a bean via:
 >  <t:saveState value="#{myBackingBean.someProperty}"/>
 >
 >Regards,
 >
 >Simon




Reply via email to