For the sake of illustration, consider a page that displays a value in two different text fields-one provided by the parent component and one by the child (see Figure 31).
CHILDCOMPONENT: ChildComponent { childValue=parentValue; };When a value is entered in a field and the change submitted, WebObjects will, if needed, synchronize the value in the parent (parentValue) and child (childValue) at each of the three stages of the request-response loop:
Given that synchronization occurs several times during each cycle of the request-response loop and that key-value coding is used to accomplish this synchronization, how does this affect the design of reusable component? It has these implications:
For instance, it's sufficient in the example shown in Figure 31 to simply declare a childValue instance variable in the child component and a parentValue instance variable in the parent. You need to implement accessor methods (such as setChildValue: and childValue) only if the component must do some calculation (say, determine how long the application has been running) before returning the value.
Let's say the parent component in the example shown in Figure 31 doesn't have a discrete parentValue instance variable but instead stores the value in some other way (for example, as an entry in a dictionary object). In that case, the parent component must provide both a parentValue method (to retrieve the value) and a setParentValue: method (to set it). During synchronization, WebObjects expects both methods to be present and will raise an exception if one is missing.
Table of Contents Next Section