How html pages are generated, Component templates – Apple WebObjects 3.5 User Manual

Page 82

Advertising
background image

Chapter 5

WebObjects Viewed Through Its Classes

82

4. It saves the session object in the session store.

5. It invokes its own

sleep

method.

When an Objective-C object is about to be destroyed, its

dealloc

method is

invoked at an undefined point in time after a cycle (indicated by the vertical
ellipses in Figure 24). In the

dealloc

method, the object releases any retained

instance variables. In WebScript, this usually happens implicitly; you therefore
usually don’t need to implement the

dealloc

method in any objects you write. In

Java, objects have automatic garbage collection, so this deallocation step is
unnecessary.

How HTML Pages Are Generated

So how exactly are request-handling messages propagated from a component to
its HTML elements? To answer this, we must understand the relationship
between a component and an HTML element.

Both components and HTML elements (static and dynamic) share a common
ancestor, WOElement (in Java, Element). WOElement declares, but does not
implement, the three request-handling messages:

takeValuesFromRequest:inContext:

,

invokeActionForRequest:inContext:

, and

appendToResponse:inContext:

. This common

inheritance, of course, makes it possible for both components and HTML
elements to participate in request handling. But there the inherited similarities
end. Although components can generate HTML content, this capability is not
an essential characteristic, as it is with objects on the other branch of the
inheritance tree.

Component Templates

The first step to generating a component’s HTML page is to create a template
for the component. This template is not the same as the HTML template
discussed in the chapter “What Is a WebObjects Application?” (page 17). In this
context, a template is a graph of WOElement and WOComponent objects
created by parsing and integrating the component’s

.html

and

.wod

files (see Figure

25). The network of references corresponds to locations on the page and to
parent-child relationships; for instance, a WOForm element would probably
have WOTextField and WOSubmitButton children.

Advertising