beautypg.com

Apple WebObjects 5 User Manual

Page 38

background image

38

A Programmer’s View of WebObjects

Apple Computer, Inc. January 2002

C H A P T E R 4

HTML-Based Applications

These advantages are discussed in more detail in the sections that follow.

Separating Presentation Code from Event-Handling
Logic

In WebObjects, a Web page is represented by a component, an object that has both
content and behavior. A component can also represent a portion of a page but
usually represents an entire page, so the word page is used interchangeably with the
word component.

Components consist of

a template in HTML code that specifies how the component looks.

This file

can be edited by any HTML editor or text editor.

event-handling logic that specifies how the component acts.

You specify this

with a standard Java source file.

bindings that associate the component’s layout specification (HTML code)
with its event-handling methods.

These bindings are stored in a text file.

Separating the presentation code, event-handling logic, and bindings makes it
much easier to maintain a Web application. A graphic artist can modify the
presentation code, thus modifying the appearance of the page, without breaking its
event-handling logic. A programmer can completely rewrite the event-handling
logic without accidentally changing the page’s layout.

You do not need to edit all three files separately. WebObjects Builder, a graphical
component editing tool provided with WebObjects Development, edits the
template, bindings, and event-handling code files simultaneously, relieving you of
having to manually synchronize them. WebObjects Builder is described in more
detail in

“WebObjects Builder”

(page 46).

Figure 4-1

(page 39) shows the three files in an example component.