Multi Counter

The multicounter is a simple extension to the Counter application. It displays several instances of the same counter component.

0

++ --

0

++ --

0

++ --

0

++ --

0

++ --

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

The first method is used to initialize the component with the default state, in this case we instantiate 5 counters:

initialize
super initialize.
counters := (1 to: 5)
collect: [ :each | WACounter new ]

We also need to tell Seaside what child components we intend to display, in our case this is just the collection of counter instances:

children
^ counters

Last but not least we display each of the components separated by a horizontale rule:

renderContentOn: html
counters
do: [ :each | html render: each ]
separatedBy: [ html horizontalRule ]