Yes agreed - I have just one ClientState object that I keep in the
session, and this wraps global state values. But I do have lots of
page-scoped @Persist'd fields - timestamps, various context/selection
id's etc which need to get cleared too.

I haven't extensively tested, but this seems to do the trick:

List<String> names = session.getAttributeNames();
  for (String name : names) {
     session.setAttribute(name, null);
}

getAttributeNames() returns all @Persist'd and SSO entities.


Cheers


On Thu, 2011-01-13 at 15:24 +0100, Joost Schouten (ml) wrote:
> Good point. I think looping over the objects sounds like a good option.
> 
> I personally try to keep all persisted state for a user in one object So 
> that I have tight conrol over what is in the session and what is not. 
> Then you only have to alter/remove one object from the session and you 
> know which one it is ;-). More and more I favour activate and passivate 
> over @Persist btw. Especially when you start combining stay logged 
> cookies and ajax. But that's a whole diferent discussion.
> 
> Good luck,
> Joost
> 
> On 13/01/11 3:16 PM, Richard Hill wrote:
> > Hi Joost,
> >
> > I'd prefer not to do it in setupRender as that will clear the session
> > even if the logged-in user has accidently hit the back button - when he
> > goes forward to the app the state will be cleared. So I'll loop over the
> > objects and do it manually.
> >
> > Cheers
> >
> >
> >
> > On Thu, 2011-01-13 at 15:09 +0100, Joost Schouten (ml) wrote:
> >> Go with the suggestion you already posted or try to invalidate the
> >> session on the setupRender of the login page in stead.
> >>
> >> Cheers,
> >> Joost
> >>
> >> On 13/01/11 2:50 PM, Richard Hill wrote:
> >>> Hi All,
> >>>
> >>> I have an app that's stateful, a fair number of @Persist'd fields on
> >>> various pages + an SSO with logged in user info.
> >>>
> >>> What I want to do is clear all of this session data when a user logs in.
> >>> The scenario here is a user logging in when he's already logged in (or
> >>> logging in as a different user when already logged in) - so I want to
> >>> start with a blank slate.
> >>>
> >>> I've tried invalidating the Session, but subsequently setting an SSO
> >>> with ApplicationStateManger throws an IllegalStateException:
> >>>
> >>>
> >>> @Inject
> >>> private ApplicationStateManager stateManager;
> >>> @Inject
> >>> private Request request;
> >>>
> >>> private void login(Client client) {
> >>>           
> >>>     Session session = request.getSession(false);
> >>>     session.invalidate();
> >>>           
> >>>     stateManager.set(ClientState.class, new ClientState(client));
> >>>
> >>> }
> >>>
> >>> which is not surprising I guess. So is it possible to create/validate a
> >>> new Session? Or is there a way to clear the Session without
> >>> destroying/invalidating?
> >>>
> >>> I've taken a look at this post here:
> >>> http://tapestry-user.markmail.org/search/?q=session+peter#query:session%
> >>> 20peter+page:1+mid:25lfcwf67itjg2ie+state:results
> >>>
> >>> which suggests looping over every ASM object. Is the best way to go?
> >>>
> >>> Thanks Richard.
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >>> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to