Iliad examples explained part I: the counter example
Iliad comes with several examples: the seaside-like counter, a simple blog using Magritte, and a todo list application.
I'll try to explain the basics of Iliad through those examples. I will start with the counter example because it is the simplest one and it will look familiar to Seaside users.
In the following it is assumed that Iliad is correctly installed.
Elements and Widgets
To use Iliad, you need to understand two important parts of the framework: Widgets and Elements.
Widgets are high level stateful graphical objects, while Elements are composite low level stateless objects for building HTML. Widgets use elements in their #contents method to build themselves.
People who are familiar with Aida/Web will immediately understand how elements work. Each XHTML tag has a corresponding element class which knows how to print itself as HTML with the #printHtmlOn: method.
e div
class: 'example';
h1: 'Hello world!'
<div class="example">
<h1>Hello world!</h1>
</div>
The #contents method of widgets used to build html returns a block closure which takes an element as parameter:
Iliad.Widget subclass: MyWidget [
contents [
^[:e |
e div class: 'example'; h1: 'hello world!']
]
]
Applications
Iliad applications are special widgets, used as entry points of web applications.
Unlike other widgets, they know how to dispatch a request to the corresponding view method.
Application subclass: MyApplication [
MyApplication class >> path [^'my_application']
index [
<category: 'views'>
^[:e |
e h1: 'Hello world!']
]
]
The #path class method is important, it tells Iliad what is the base path of the application.
View methods in applications are pretty much like the #contents method of widgets. By default, they must be in the 'views' method protocol, else they won't be allowed to be used as view methods.
The #index method is the default view method, so this view can be reached at:
http://localhost:xxxx/myApplication/index or http://localhost:xxxx/myApplication
The counter widget example
Let's take a look at the Counter widget class.
Iliad.Widget subclass: Counter [
| count |
initialize [
super initialize.
count := 0
]
contents [
<category: 'building'>
^[:e |
e h2: count printString.
e anchor
action: [self increase];
text: '++'.
e space.
e anchor
action: [self decrease];
text: '--'.]
]
decrease [
<category: 'actions'>
count := count - 1.
self markDirty
]
increase [
<category: 'actions'>
count := count + 1.
self markDirty
]
]
A counter widget has a count instance variable, initialized to 0. Its #contents method builds a header displaying the current count value, and two anchors, one to increase the count, and one to decrease it.
There is something new in this #contents method: the actions associated to the anchors. Actions are block closure that will be evaluated when the user clicks on the associated link or button. Here we use them to modify the count value with #increase and #decrease methods.
Also note the #markDirty call in #increase and #decrease. These method is really important when updating the state of a widget. It tells Iliad
that the widget's state has changed, so it will be rebuilt.
The counter application
The counter widget is, like all Iliad widgets, a standalone graphical object. Let's create a simple application to see it in action!
Iliad.Application subclass: CounterApplication [
| counter |
CounterApplication class >> path ['counter']
counter [^counter ifNil: [counter := Counter new]]
index [
<category: 'views'>
^[:e |
e build: self counter]
]
]
As you may have noticed, the counter widget is stored into an instance variable, so a new one won't be created on each request. This is important, because our counter has state, and it must be maintained between requests.
Also, we don't call the #contents method of the widget directly. it should never be called from the outside.
That's it, you can see your counter at:
http://localhost:xxxx/counter
Happy Iliad hacking!
NOTE1: When trying the counter example, you will notice that the widget is updated with AJAX requests. Iliad has a nice javascript layer which does that for us :). If javascript is disabled, it will degrades to normal requests, but the behaviour will remain the same.
NOTE2: The counter example code is available in the More/Examples/ directory. The CounterApplication is a bit more complete, and shows also a multi-counter example.

I am wondering whether you considered any alternative to HTML+JavaScript - for example, Curl ( as in www.curl.com and not cURL as in haxx.de)
Curl now has some opensource projects at sourceforge.net
It seems to me from looking through the code (now that I finally got GST 3.1 + Swazoo 2.2 via git to build on thie EeeBuntu netbook) that an Element class hierarchy for Curl is very do-able.
Curl is not well-known in France (must published users are in Japan) and until Thomson Reuters ever reveals the extend of Curl users in corporate Europe, that has to remain an unknown.
What makes Curl interesting now is Semantic Web: Curl macros for SemWeb ( RDF or Topic Maps) look no different from the web content markup. But macros are always defined in a secondary package and packages can be loaded dynamically. So depending on which package you load, the macros are harmless wrappers on some markup or the basis for navigational or other analysis. To give just one hint - Curl did not need to add such things as REL and REV.
If you wanted to indicate that Topic Map information can be read from a given piece of markup you might simply wrap it in {t } and a subject-identifier in {si } or an association in {a }
These "tags" are also very similar to how clauses can be "tagged" in Erlang which raises the prospect of a GST+Erlang hybrid ( and very similar to the "functors" of the prolog from www.pdc.dk