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:
In this case, WOComponent (Component in Java) defines the application method, which returns the WOApplication object (WebApplication in Java).
If the method is not found, it looks for an upSince instance variable. In this case, the upSince instance variable is defined in the application's code file.
Because upSince is a date object, it defines a description method, which prints the object's value as a string.
Note: The Java equivalent of the description method is toString, but you must use the WebScript name for methods and literals in the .wod file even though the application is written in Java.
For example, dictionary objects store key-value pairs. Suppose you declare a person dictionary that has the keys name, address, and phone. These keys aren't really instance variables in the dictionary, but because WebObjects accesses values using key-value coding, the following binding works:
myString : WOString { value = person.name };
Even if your entire application is written in Java, you must use the Objective-C names for methods and for literals. For example, you must use YES instead of true, NO instead of false, and description instead of toString.
Table of Contents Next Section