There isn't a one-to-one correlation between dynamic elements and variables. Most dynamic elements have several attributes, and you bind each attribute to a different variable or method in your script. For example, WOTextField defines three attributes that define very different things: value specifies the value the user enters in the text field, name specifies a unique identifier for the text field, and disabled specifies if the field is enabled or disabled. If you wanted non-default values for all three attributes, you'd bind them to three different variables.
To bind an element, you must specify three things:
This binds aGuest.name to the value attribute of the WOTextField labeled Name. After you perform this step, the text "aGuest.name" appears in the text field to show that it has been bound. A status message appears in the upper right corner of the editing display saying the binding has been made to WOTextField's value attribute. This means that aGuest.name represents the value entered in the Name field.
Unlike the text fields, the multi-line text element won't update to show you which variable it is bound to, but you will still receive the status message "bound to value."
At the beginning of this section, you learned that WOTextFields have three attributes: value, name, and disabled. Why didn't you have to make a binding to all three? Because name and disabled are optional attributes. If you don't bind variables to them, WebObjects assigns them default values. It creates a unique name to refer to the WOTextField, and it enables the text field by default. Later, you'll see an example of a dynamic element that has more than one variable bound to it.
Table of Contents Next Section