Apple WebObjects 3.5 User Manual

Page 97

Advertising
background image

Benefits of Reusable Components

97

Figure 28. An Alert Panel

This panel is similar to the navigation table shown in Figure 27, but as you’ll
see, most of the component’s attributes are customizable.

To use this component, you simply declare its position within the HTML
page and give it a name:

<HTML>
<HEAD>

<TITLE>Alert</TITLE>

</HEAD>
<BODY>

<WEBOBJECT NAME = "ALERT"></WEBOBJECT>

</BODY>
</HTML>

The declarations file specifies the value for each of the panel’s attributes,
either by assigning a constant value or by binding the attributes value to a
variable in the component’s code (as with the

alertString

and

infoString

attributes

here):

ALERT: AlertPanel {

alertString = alertTitle;
alertFontColor = "#A00000";
alertFontSize = 6;
infoString = alertDescription;
infoFontSize = 4;
infoFontColor = "#500000";
tableWidth = "50%";

};

The component’s code defines the

alertTitle

and

alertDescription

instance

variables or methods, which set the text that’s displayed in the upper and
lower panes of the alert panel. The

alertDescription

method could, for example,

consult a database to determine the release date of the video.

WebObjects Builder makes working with reusable components such as
AlertPanel even easier. Component clients can simply drag the alert panel
into their components and use the Inspector to set the bindings. They don’t
need to manually edit the declarations file to set these bindings. To set this
up, you, as the component creator, edit a file named

AlertPanel.api

specifying

both required and optional attributes. You could, for example, export only

Advertising