The visit pattern certainly isn't deprecated, it just evolved. Instead of having a single visit object to store everything, you define your own application state objects. It's a vast improvement because you can separate each functional area of your application into its own ASO with whatever API it needs. I often find myself creating an ASO called "visit" for some general purpose usage, but using other ASOs as well.

Anyway, I was assuming you were storing your state with each individual page using @Persist annotations rather than stashing it all in an ASO. If state is local to a certain page, it belongs in that page. If it's shared between pages, then use the ASO.

If you're just looking for a way to simplify the check, I'd create a marker interface to denote stateful pages and have your check be for event.getRequestCycle().getPage() instanceof StatefulPage. That way you're not hardcoding lists. You should only need to do this on rewind OR render, depending on whether you're checking against the requesting or responding page.

-Steve

Gareth wrote:
Thanks Steve.

I'll investigate using that perhaps instead of storing it in the visit object.  
Incidentally, I haven't had any comments as to whether the visit pattern is no 
longer the best practice with version 4.1.1 upwards...  I'd be grateful to hear 
people's views.  I think the reason I'm not clear is because I don't know the 
reasoning behind the getVisit() method being deprecated - so I wrote my own 
that kind of does the same thing - getTheVisit().

Currently, my solution is to have my BasePage (which extends the Tapestry 
BasePage) implement PageBeginRender, it then checks the page being opened to 
see if it is one of my 2 for which I want state to be kept, and if it isn't, it 
clears the state out of my visit object - which is where i moved the state to 
since it is easier to get to there.

If anyone has a tidier solution - because I think that this method has to be 
about the most inefficient (forcing a check of the page 2x per requestCycle for 
every page in the application), I would be very grateful to hear it.

Thanks

Gareth

----- Original Message ----
From: Steve Shucker <[EMAIL PROTECTED]>
To: Tapestry users <users@tapestry.apache.org>
Sent: Wednesday, 4 April, 2007 9:54:52 PM
Subject: Re: Page Cleanup Tasks

I'm not sure where you'd call it from, but IRequestCycle.forgetPage(String) will cause it to dump any state connected to a given page.

-Steve

Gareth wrote:
hi,

I am storing a list of items in the session using @Persist("session") and that 
is working well, however I would like to remove that list from the session if that area 
of my application is left by the user.  Is it possible to establish via the 
PageDetachListener or some other method which page the user has decided to jump to from 
my menu, and dependant on that page, clear / keep my session variable?

Many thanks

Gareth



___________________________________________________________ New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






                
___________________________________________________________ Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to