Seaside renders HTML programmatically. Most Java frameworks render HTML with templates. I don't know enough to advocate one method over another, but it's certainly different, and it works well in Seaside's model.
Seaside has a model for components. A Seaside component manages user interface state and renders itself in HTML. Seaside components are highly reusable, and they let you think in increments smaller than a page.
Seaside makes it easy to manage a link. You can specify a link with a code block, so links don't get out of sync. The framework manages them for you.
Seaside is modal. This is the author's word for a continuation server approach. Seaside lets you express one web page, or multipage web flows, in a single method.
Seaside's debugging is the best I've ever seen. From within the browser, you can open a web-based Smalltalk browser, complete with code. You can also inspect the values of all the objects in the application.
Of course, you also get the advantages of using a highly dynamic language. You get a rapid feedback loop, interactive interpretation as needed, and full access to Smalltalk's excellent environments. I used the Squeak IDE for examples in this chapter. Squeak is a dialect of Smalltalk popularized by Disney.
A Little Smalltalk Syntax
Before we get too far, you should know a little Smalltalk syntax. Don't worry. I'm not saying that Smalltalk is the next great language; I just want you to see the power of the best continuations-based server. If you want to follow along, download the Squeak IDE from
http://www.squeak.org/. Start Squeak, click on Tools, and drag a workspace and transcript window onto your desktop. Use your workspace window for input, and look to the transcript window for output.
Smalltalk syntax is quite simple. Type an object name first, the method second, and any parameters third. Let's evaluate a few statements. In your workspace, type:
Transcript show: 'Hello'
Highlight it, right-click, and then select do it from the menu. (You can also use Alt-D before you press Enter, to evaluate the line.) You should see the word Hello in your Transcript window. transcript is the object, show: is the method (Smalltalk calls methods messages), and 'Hello' is a parameter.
Like Ruby, Smalltalk supports code blocks, though the syntax is a little different. Evaluate this:
1 to: 5 do: [:i | Transcript show: i]
First, you see that [ and ] mark the beginning and end of the code block. i is a parameter for the code block. In the declaration, you'll precede it with a colon.
Let's try multiple statements. Smalltalk terminates statements with a period. Logic uses messages and code blocks :
age := 4. (age > 16) ifFalse: [Transcript show: 'Youngster.'] ifTrue: [Transcript show: 'Old timer.']
This bit of code sets age to 4 with the := message. Then, it sends the ifFalse: method to the (age > 16) expression. The first code block is a parameter for ifFalse, and gets called if the expression evaluates to false.
You can see the influence of the elegance of Smalltalk in Java, and other languages, too. Java's garbage collection, design patterns, and collections all share Smalltalk's influence. Consider Hibernate's use of message chaining . If a method doesn't have a return value, it simply returns itself, enabling tighter code like this:
cfg.add("pet.hbm") .add("vet.hbm") .add("pet.hbm");
Many ideas from Eclipse have roots in IBM's VisualAge for Java , which first shared IDE code and a virtual machine with a Smalltalk product. Smalltalk syntax is wonderfully consistent.
A Seaside Overview
Seaside is a Smalltalk framework and a server. Remember, a continuation server is different from other web servers, so Seaside must run in its own environment. In Squeak, you'll left-click on the desktop to give you a menu (called the world menu). Then, you'll select Open... SqueakMap Package Loader. Use it to install four packages: DynamicBindings, KomServices, KomHttpServer, and Seaside, in that order. Now, your Smalltalk image has Seaside. To see it, fire up the server. In Squeak, you'll open a workspace and evaluate:
WAKom startOn: 9090
WAKom is the name of the server. starton: is a method that tells the server to start on a supplied port, 9090 in this case. In some ways, WAKom is like Tomcat, or any other web application server. You can configure it by pointing your browser to:
You'll see Seaside's configuration screen. Some of the items should look familiar to you. You'll see a list of registered applications, and some configuration options. Later, it will become clear that Seaside is more than Tomcat in Java.