Counter

The counter is the most basic example of a Seaside web application. It allows to increment and decrement a number by hitting a link.

0

++ --

This application can be written with a few lines of code. It is implemented in the class WACounter, a subclass of WAComponent.

The first method is used to initialize the component with the default state, in this case we set the counter to 0:

initialize
super initialize.
count := 0

The second method is used to generate the output. It also assigns the actions to the anchors (links) that update the current value.

renderContentOn: html
html heading: count.
html anchor
callback: [ count := count + 1 ];
with: '++'.
html space.
html anchor
callback: [ count := count - 1 ];
with: '--'