myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Stone <>
Subject t:saveState works with tabs - but I don't know why!
Date Fri, 11 Jun 2010 22:46:02 GMT

Using myfaces 1.2.8 and tomahawk12 1.1.9, I've implemented a JSF page 
with a request-scoped backing bean and which employs t:saveState to hold 
some of the page's state between requests.  My original goal was to find 
a way to allow multiple tab/window-copies of the page to act 
independently without the cross-talk that occurs in a session-scoped 
backing bean across windows/tabs.

I thought I had hit a setback when I realized that the "id" parameter 
for t:saveState could not be an EL expression -- I had originally 
intended to use a window UID as an EL expression to differentiate 
storage objects between tabs/windows; without such differentiation, 
surely each tab/window would overwrite the single storage object with 
its own data.  This was indeed the case; switching tabs mixed the state 
information between the tabs.

Then, in preparation for another line of attack, I added a hidden field 
on the JSF; I initialize this hidden field with the current time when 
the page is first accessed via URL.  I intended to use these as UIDs for 
an array of state-saving objects, one for each tab/window, that got 
saved in its entirety in the t:saveState object.  I really dreaded 
implementing such a monster, btw.  However, just adding this unique id 
in a hidden field somehow made state-saving work independently across 
tabs and windows!

I'm very happy that this works, and very uncomfortable not understanding 
why.  Can anybody shed some light on this little miracle for me? Are 
there somehow separate view trees (where t:saveState stashes the 
persistent object) for each tab/window now, just because of the hidden 
uid? Or (this seems less likely to me) are there separate saveState 
objects for each window/tab (why would there be)?

As an aside, I'd really love to be able to look at the state of the view 
tree to figure this out; does anyone know of a way to do that?



View raw message