Table of Contents Previous Section Binding Elements

Binding Elements

  1. Select an element.

  2. Double-click a variable in the object browser.

A message appears in the upper right corner of the component window's editing display. The message tells you what attribute the variable is bound to.

Bindings are the key to writing dynamic HTML pages in WebObjects. A binding is a mapping between a variable or method declared in a component's script and a dynamic element in the component's HTML.

Each dynamic element defines one or more attributes. You can bind each attribute to a different variable or method in your script. Thus, there is not a one-to-one correlation between dynamic elements and variables. To bind an element, you must specify three things: the variable (or method), the element, and the attribute within the element.

Many times, WebObjects Builder can determine which attribute you want to bind to without you having to explicitly specify the attribute. For example, if you select a WORepetition and double-click an array, WebObjects Builder binds the array to the list attribute. If you select a WORepetiton and double-click a variable that isn't an array, WebObjects Builder binds the variable to the item attribute (which represents a single item in the WORepetition's list).

For each dynamic element, WebObjects Builder chooses the attribute that is most commonly used, given the class of the double-clicked variable. Thus, double-clicking a variable should produce the binding you want most of the time.

You can override WebObjects Builder's default bindings by binding using the inspector instead of double-clicking. You might need to do this when:

To learn more about a dynamic element's attributes, look it up in the "Dynamic Elements" section of the WebObjects Reference. Also, you can select the attribute in the bindings inspector to see a short description of the attribute.

Table of Contents Next Section