Apple WebObjects 3.5 User Manual

Page 77

Advertising
background image

How WebObjects Works—A Class Perspective

77

class for the page named “Main.” The application object performs the
following steps to create a component:

1. It looks in the runtime system for a WOComponent subclass that has

the same name as the request page (in this case, “Main”). If it finds such
a class with the same name, it creates an instance of that class.

2. If the application object fails to find a class in the runtime system, it

looks for a scripted component with the name of the request page.
When it finds the

.wo

directory, it creates a component object using a

unique WOComponent subclass for the scripted component and makes
the scripted code the class implementation.

3. It invokes the WOComponent subclass’s

init

method or constructor.

4. It invokes the WOComponent subclass’s

awake

method to prepare it for

the request.

If the request is made from an established session, the application object
attempts to retrieve the request page from its cache. By default, an
application caches component (or page) instances once they’re created,
primarily to facilitate backtracking: when users backtrack, they’re revisiting
pages restored by the application. The request URL contains the
information needed to retrieve the page from the cache (see Figure 21).
This information includes the page name and a context ID.

The component may not be in the cache for one of three reasons:

The page-caching feature is turned off.

The request is the first for that page during the session.

The user has backtracked beyond the page cache limit.

If the component is not in the cache, the application object creates the
component using the procedure described above. If the component is in the
cache, it sends the component the

awake

message.

Note that to retrieve the page from the cache, a context ID is required in
addition to the page name. The context ID identifies a page as it existed at
the end of a particular request-response loop
. Why is the context ID necessary?
Imagine you’re accessing a WebObjects application that lets you subscribe
to various publications. You navigate from the site’s home page to the order
page, where you select a publication, and then you go to the customer
information page and fill in your address. After submitting this information,
you navigate back to the home page. Next, you decide to enter a

Advertising