Dynamic Web Development with Seaside

6.3.5Adding Behavior to the Counter

Now we can add some actions by defining callbacks attached to anchors. We will explain actions in detail later in this book. A callback is a piece of code that will be executed when a link is clicked. For now this is just to give you a feel of Seaside programming. We update the WebCounter>>renderContentOn: method as follows.

WebCounter>>renderContentOn: html
html heading: count.
html anchor
callback: [ self increase ];
with: '++'.
html space.
html anchor
callback: [ self decrease ];
with: '--'

After saving your changes, refresh the browser page and you will now see the increment and decrement links. Click on the links so see that the counter get incremented or decremented, see Figure 52.

VAST sample counter with actions

Copyright © 19 March 2024 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.