Documentation Archive Developer
Search
Table of Contents Previous Section

Bind the WORepetition element

Just as you had to bind the input elements to variables so that the input values could be captured in the script, you now have to bind the output elements to script variables so that the page displays the correct information.

  1. Click the first field inside the WORepetition, and double-click guests under application in the object browser.

    This binds the guests array to the list attribute of WORepetition. WebObjects Builder automatically creates a variable called guest and binds it to the item attribute (the second field in the repetition).

  2. Bind each item in the variable guest (name, email, and comments) to the three WOStrings inside the WORepetition by selecting the WOString and double-clicking the variable.

  3. Save the Main component.

A closer look

You just bound the WORepetition's list attribute to the application script's guests array, which you created earlier. A WORepetition displays its contents for each item contained in its list attribute. When you created the WORepetition, you defined its contents as three WOStrings. Then, you bound those WOStrings to the information in the newly created variable guest, which is updated to contain the current item in the list as WORepetition moves through the list.

Creating a WORepetition and binding it in this manner is the equivalent of saying "for each guest item in the guests array, display the name, e-mail, and comments."

WORepetition is an example of a dynamic element that requires bindings to two different variables. The list attribute is bound to the guests array, and the item attribute is bound to the variable guest. WOString, on the other hand, is like the WOTextFields and WOText that you bound earlier: WOString defines multiple attributes, but you only need to bind to one attribute, the value attribute, for the string to work properly. The other attributes are assigned default values.

You can learn more about WORepetitions, WOStrings, and the other dynamic elements in this example by looking them up in the Dynamic Elements section of the WebObjects Reference. To learn more about how to use WebObjects Builder to create dynamic elements, see "Using Dynamic Elements in WebObjects Builder."

Table of Contents Next Section