Apple WebObjects 3.5 User Manual
Page 108

Chapter 6
Creating Reusable Components
108
This declaration specifies a value for just one attribute; all others will use
the default values provided by the component’s
init
method:
Partial Declaration
ALERT: AlertPanel {
alertString = "Choice not available.";
};
•
Consider building reusable components from reusable components.
Rather than building a monolithic component, consider how the finished
component can be built from several, smaller components. You may be able
to employ these smaller components in more than one reusable
component.
Take, for example, the AlertPanel example shown in Figure 28 (page 97).
See the ReusableComponents example application to view the source code
for this component. The AlertPanel lets you not only set the message
displayed to the user, but also the message’s font size and color. These font
handling features aren’t provided by the AlertPanel itself but by an
embedded reusable component, FontString. FontString itself is a versatile
component that’s used in many other components.
•
Document the reusable component’s interface and requirements.
If you plan to make your components available to other programmers, you
should provide simple documentation that includes information on:
•
What attributes are available and which are required.
•
What the default values are for optional attributes.
•
What context needs to be provided for the component. For example,
does it need to be embedded in a form?
•
Any restrictions that affect its use. For example, is it possible to have a
submit button in the same form as the one that contains this
component?
In addition, it’s helpful if you provide an example showing how to use your
component.