Apple WebObjects 3.5 User Manual

Page 32

Advertising
background image

Chapter 2

Dynamic Elements

32

This list is not hard-coded into the page. Instead, it is produced by several
dynamic elements. Figure 10 shows how this same part of the page looks in
WebObjects Builder.

Figure 10. CyberWind Main Page in WebObjects Builder

The elements shown in Figure 10 are a WORepetition, a WOHyperlink, and a
WOString. The WORepetition element corresponds to a

for

loop in C code.

That is, it iterates through a list of items and, for each item in that list, prints its
contents. In this example, the contents are a WOHyperlink and a WOString.
The WOHyperlink is a hyperlink whose destination is determined at runtime,
and the WOString is a string whose contents are determined at runtime.

When you run CyberWind, the WORepetition walks through an array of strings
that the component’s code supplies. For each item in the array, it displays a
hyperlink whose text is the text of the string item in the array. In this array, there
are two strings—“See surfshop information” and “Buy a new sailboard”—so the
WORepetition creates two hyperlinks, each containing the appropriate text.

As the name implies, server-side dynamic elements operate entirely on the
server (see Figure 11). That is, when a server-side dynamic element is asked to
draw itself, it returns HTML code that should form part of a page, the page is
constructed, and then the entire page is sent from the server to the client. Later
in this chapter, you’ll learn about client-side components, which transport
values and state from the server to the client and then draw themselves on the
client machine.

Advertising