As we proceed and introduce new brushes, we will provide a table describing the parts of the Brush API that are essential for this book. Once you’ve used the table to find the brush to use for a given tag, you can read the source code for that brush class to find out how to use it. For example, if you want to produce a heading such as <h1>Something great</h1> you’ll see that you should use the WAHtmlCanvas>>heading message which produces a brush instance of WAHeadingTag which has the following API:

Methods in WAHeadingTag

Description

level:

Specify anInteger as the heading level for this brush.

with:

Render this heading tag with anObject as its body.

To help you to find the correct brush, the brushes are presented from the perspective of the HTML tags in the following table:

Smalltalk typically encourages explicit naming and avoids abbreviations — the few seconds per day you save by typing an abbreviated method or variable name may often come back much later to haunt you or someone else reading your code as minutes or even hours spent trying to debug code with poor readability.

This book is not a complete Seaside reference. Once you’re done reading it you will want to discover new brushes and brush options yourself. Let’s take a few moments to describe how you would do that.

Suppose you know a specific XHTML tag you want to use and need to find the appropriate brush method. Some brush method names are the same as the corresponding XHTML tag name. For example you create a div tag using the WAHtmlCanvas>>div brush method. In other cases the brush name is the long form of the equivalent XHTML tag (WAHtmlCanvas>>paragraph creates a p tag, WAHtmlCanvas>>unorderedList creates a ul tag etc). This choice makes your methods a lot more readable than if the XHTML tags were used everywhere. Compare the following two code fragments.

"This is not working code"htmlpwith:'Hello world.'.htmlolwith:[htmlli:'Item 1'.htmlli:'Item 2'].

If you can’t guess the brush method name just open a class browser on the canvas class WARenderCanvas. Keep in mind that the method you’re interested in may be in a superclass, see the hierarchy below.

Normally, the brush configuration methods that set tag attributes, use the same name as the attribute. So, for example, to set the altText attribute for an IMG (image) tag you’d send the image brush the WAImageTag>>altText: message. If you don’t know the tag attribute you need to open a class browser on the specific brush class. Once again, keep in mind that the method you’re interested in may be in a superclass. In addition to tag attributes, many of the Seaside brushes support convenience methods and common Javascript hacks (like setting the focus of an input field). The best way to find these is to use your Smalltalk tools.

When you first begin using Seaside your canvas and brush vocabulary will be limited and it might take you a few minutes to find what you’re looking for. After a while you’ll discover that there is a significant shared API (implemented in the abstract superclasses) and that you are already familiar with many of the brushes. Also helpful is the autocompletion mechanism in the development environment.