Apple WebObjects 3.5 User Manual

Page 140

Advertising
background image

Chapter 7

Managing State

140

A WebObjects application handles a page-refresh request differently than it
would a standard request. When the application determines that the request
URL is identical to one it has previously received (that is, the session and
context IDs in the request URL are identical to those in a request it has
previously received), it simply returns the response page that was associated
with this earlier request. The first two steps of a normal request handling loop
(value extraction from the request and action invocation) don’t occur.

Page Refresh and WODisplayGroup

If you’re using a WODisplayGroup object in your application, you must enable
page refresh so that the application and the client browser stay in agreement
about which objects are being displayed.

A WODisplayGroup holds a set of objects (generally enterprise objects fetched
from a database) and provides “batched” access to these objects. For example,
if a user submits a query (such as, “Show me the movies released in 1996.”) to a
Movies application, a WODisplayGroup might return 10 records at a time to the
user’s browser. The application would offer controls to let the user display the
next and previous batches of 10 movie titles. When the user decides to order one
of the movies, the WODisplayGroup needs to know which batch the item
comes from.

As the user presses the Next Ten Movies or Previous Ten Movies buttons, the
WODisplayGroup updates its record of which 10 movies are being displayed.
When the user decides to order the second movie in the list, the
WODisplayGroup can determine the actual record since it knows which batch
is being displayed and which record is number 2 in that batch. But if the user
backtracks to a previous page (with page refresh disabled) and chooses the
second record, the WODisplayGroup will erroneously pick the second record
from its current batch. By enabling page refresh, the WODisplayGroup is
alerted each time the user backtracks and can update its notion of the current
batch, eliminating this problem.

Advertising