Apple WebObjects 3.5 User Manual
Page 101
Intercomponent Communication
101
invoked by the child. In this example
parentAction
identifies the parent
method named
"respondToAlert"
, as specified in the parent’s declarations file.
Note:
You must enclose the name of the parent’s action method in quotes.
Now, looking at the
rejectChoice
and
acceptChoice
method implementations, you
can see that they are identical except for the assignment to
exitStatus
. Note
that after a value is assigned to
exitStatus
, the child component sends a
message to itself to invoke the parent’s action method, causing the parent’s
respondToAlert
method to be invoked. Since the parent’s
usersChoice
variable is
bound to the value of the child’s
exitStatus
variable, the parent code can
determine which of the two links was clicked and respond accordingly.
Figure 30 illustrates the connections between the child and parent
components.
Figure 30. Parent and Child Component Interconnections
The child component’s
parentAction
attribute provides a separation between a
user action (such as clicking a hyperlink) within a reusable component and
the method it ultimately invokes in the parent. Because of this separation,
the same child component can be used by multiple parents, invoking
different methods in each of them: