Apple WebObjects 3.5 User Manual

Page 102

Advertising
background image

Chapter 6

Creating Reusable Components

102

Parent1’s Declarations File (excerpt)

ALERT: AlertPanel {

...
parentAction = "respondToAlert";
exitStatus = usersChoice;

};

Parent2’s Declarations File (excerpt)

ALERT: AlertPanel {

...
parentAction = "okCancel";
exitStatus = result;

};

Parent3’s Declarations File (excerpt)

ALERT: AlertPanel {

...
parentAction = "alertAction";
exitStatus = choice;

};

In summary, parent and child components communicate in these ways:

A parent component can, in its declarations file, set child component attributes
by:

Assigning constant values

Binding an attribute to the value of a variable declared in the parent’s code

Binding an attribute to the return value of a method defined in the parent’s
code

A child component can communicate actions and values to a parent component
by:

Invoking the parent’s callback method

Setting variables that are bound to variables in the parent, as specified in the
parent’s declarations file

Synchronizing Attributes in Parent and Child Components

Because WebObjects treats attribute bindings between parent and child
components as potentially two-way communication paths, it synchronizes the
values of the bound variables at strategic times during the request-response
loop. This synchronization mechanism has some implications for how you
design components.

Advertising