PATH Documentation > WebObjects

Up Previous Next

Dealing With Browser Backtracking

Synopsis

Describes solutions to the page synchronization issues that arise when users backtrack with the browser.

Discussion

A problem can arise in WebObjects when users are allowed to backtrack using the browser. The problem is that browsers normally cache the previous pages and repaint the cached pages when the user backtracks. The old page might contain items that are no longer part of the current result set. Thus, the user may get a response for an item he has not selected.

For example, suppose that you have a page capable of showing either a list of movies or the details of one movie. In addition, based on a detail mode flag, a WOCondition decides to show the details. Furthermore, the user clicks a movie title within the list of titles, detail mode is toggled on, the selection is remembered, and the same page instance is returned. If the user presses the browser's back button, the browser simply repaints the page with the list of movie hyperlinks. This is where the problem arises. The current state of the page is set to detailed mode. When the user selects another movie title from the list, WebObjects must figure out which action should be invoked. It does this by running through the components on the page and determining which element was selected. Since the current state is detail mode, only the detail WOCondition block of elements are checked and a mismatch occurs.

There are two ways to work around this problem.

Option 1: Generate Preexpired Pages

When you set the WOApplication setPageRefreshOnBacktrackEnabled method to YES, WOF generates preexpired pages. This informs the browser that it must refetch the page whenever the browser is going to move back to the page.

The issues with this solution are as follows:

Option 2: Return a New Page Instance for Every Action

Create a new instance of the current page and push all of the current state into that page. Make state changes in this new page and then return the new page from the current page's action. This ensures that every page keeps its original state for future requests from a backtracking user.

The issues with this solution are as follows:

There are many different combinations of these two approaches that can be used throughout a WebObjects application. You must think through the issues of both and perform some basic testing within your environment to see what works best.

See Also

Questions

Keywords

Revision History

24 July, 1998. David Scheck. First Draft.
19 November, 1998. Clif Liu. Second Draft.

 

© 1999 Apple Computer, Inc.

Up Previous Next