[Seaside] WAComponent instances tree + proper page refreshing for user (back button) - confusion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Seaside] WAComponent instances tree + proper page refreshing for user (back button) - confusion

Petr Fischer
Hello, sorry for crossposting (from Seaside list), but I probably do not understand something very basic in Seaside - how to properly refresh instantiated WAComponent tree (data views) and when (+ back button problems).

Seaside manual says ("About Callbacks" section):

"Do not change state while rendering... Just produce output and define callbacks that do the fancy stuff you can’t do while rendering."

OK, then my small example:

1) Suppose I have a page - WAMyListPage (WAComponent sub class), which presents a list of items from DB table, easy.

2) When WAMyListPage is instantiated at the beginnig, it loads 10 rows from the DB, creates WAMyItem (WAComponent subclass) for every DB row and puts these WAMyItem instances to the WAMyListPage instance variable "items" (OrderedCollection)

3) WAMyListPage is rendered to the browser (simple render call on all WAMyItem "items" components in a loop) - 10 items (db rows) are displayed - OK

4) User 1 clicks on the WAMyItem component from the rendered list (on the WAMyListPage) and goes into item detail page (detail page is not interesting here)

5) User 2 deletes 5 items/rows from the database (some way)

6) User 1 clicks browser back button and returns to the WAMyListPage, two cases can occur:

                A) typically, the "list page" is cached in the browser and browser immediatelly renders the list page from the cache (without request) - with all 10 old items (no refresh, broken old view with some non existing items)

                B) request from the browser to the Seaside app is made again (with old Seaside URL from browser history), then Seaside app just renders old state of WAMyListPage instance from the history and again - there is all 10 old WAMyItem items instantiated, so, broken again, old items in the view

My question - where can I do a proper refresh of WAMyListPage list items? (manual refresh button in the Seaside app is unacceptable)

Note: I can solve this by reloading WAMyListPage "items" instvar collection in every renderContentOn: (reload from DB, reload all WAMyItem instances) + instruct the browser to not cache any web page (in HTTP headers), so in point (6A) above, browser will ignore caching and make request to Seaside app again.
In this way, everything works, WAMyListPage is actual every time, but main Seaside rule "Do not change state while rendering" is violated (WAMyItems are reinstantiated in every renderContentOn:).

So, how do I face this? Thanks very much! pf