Bindings – Apple WebObjects 3.5 User Manual

Page 22

Advertising
background image

Chapter 1

What Is a WebObjects Application?

22

as shown in Figure 2. (In Project Builder, Java and Objective-C code files are
shown under Classes instead of with the component under Web Components.)

Figure 2.

Location of Code File for Java Component

You can mix languages. It’s common to use WebScript to write your interface
logic (that is, the files described in this chapter) and use Java or Objective-C to
write your business logic. Many simple applications are written entirely in
WebScript. Some programmers prototype using WebScript and then create a
compiled version of the same application to improve performance.

Bindings

You use a declarations file (

Main.wod

) to define the bindings, or mapping, between

the methods and variables you defined in your code and the dynamic elements
in your template. For example in the HelloWorld application, the HTML
template for the Main component contains two dynamic elements. The
declarations file specifies that the first dynamic element represents a text field
whose value maps to the

visitorName

variable in the component’s script. When the

user types a name in the text field, WebObjects assigns it to the

visitorName

variable. The declarations file also specifies that the second dynamic element is
a submit button and that when the user clicks the button, WebObjects invokes
the

sayHello

method.

Main.html

Main.wo

Main.wod

Main.java

HelloWorld

Advertising