Apple WebObjects 3.5 User Manual

Page 95

Advertising
background image

Benefits of Reusable Components

95

<HTML>
<HEAD>

<TITLE>World Wide Web Wisdom, Inc.</TITLE>

</HEAD>

<BODY>
Please come visit us again!

<!-- start of navigation control -->
<WEBOBJECT NAME="NAVCONTROL"></WEBOBJECT>
<!-- end of navigation control -->

</BODY>
</HTML>

The thirteen lines are reduced to one, which positions the WebObject
named NAVCONTROL. The declarations file for this page binds the
WebObject named NAVCONTROL to the component named
NavigationControl:

NAVCONTROL: NavigationControl {};

All of the application’s pages would have entries identical to these in their
template and declarations files.

NavigationControl is a component that’s defined once, for the use of all of
the application’s pages. Its definition is found in the directory

NavigationControl.wo

in the file

NavigationControl.html

and contains the HTML for the

table:

<CENTER>
<TABLE BORDER = 7 CELLPADDING = 0 CELLSPACING = 5>
<TR ALIGN = center>

<TH COLSPAN = 4> World Wide Web Wisdom, Inc.</TH>

</TR>
<TR ALIGN = center>

<TD><A HREF = "http://www.wwww.com/home.html"> Home </a></TD>
<TD><A HREF = "http://www.wwww.com/sales.html"> Sales </a></TD>
<TD><A HREF = "http://www.wwww.com/service.html"> Service </a></TD>
<TD><A HREF = "http://www.wwww.com/search.html"> Search </a></TD>

</TR>
</TABLE>
</CENTER>

Since NavigationControl defines a group of static elements, no declaration
or code file is needed. However, a reusable component could just as well be
associated with complex, dynamically determined behavior, as defined in
an associated code file.

Now, to change the navigational control on all of the pages in this
application, you simply change the NavigationControl component. What’s
more, since reusable components can be shared by multiple applications,

Advertising