Documentation Archive Developer
Search
Table of Contents Previous Section

Binding Values to Dynamic Elements

In the CyberWind example, all of the dynamic elements are bound to variables and methods from the component that contains them (the Main component). It's common to bind to variables and methods declared directly in the current component; however, you can bind to any value that the component can access.

This means, for instance, that you can bind to variables from the application or session object because the WOComponent class declares two instance variables, application and session, which point to the current application and the current session. Look at CyberWind's Footer component in WebObjects Builder. This component displays, among other information, the date and time the CyberWind application was started.This date is stored in the application object, not in the Footer component. The Footer component's .wod file contains this declaration:

	UP_SINCE:WOString {value = application.upSince.description};
To retrieve a value from this binding, WebObjects uses key-value coding, a standard interface for accessing an object's properties either through methods designed for that purpose or directly through its instance variables. With key-value coding, WebObjects sends the same message (takeValue:forKey:, or takeValue in Java) to any object it is trying to access. Key-value coding first attempts to access properties through accessor methods based on the key's name.

For example, to resolve the binding for the WOString element in the Footer component using key-value coding, WebObjects performs the following steps:

Here are the general rules for binding dynamic element attributes:

Table of Contents Next Section