Dynamic Web Development with Seaside

Buy PDF Buy Print

4.2.5Adding Behavior

Now we can add some actions by defining callbacks attached to anchors, see Figure 37. A callback is a piece of code that will be executed when a link is clicked. We will explain this in detail later in the book. Modify the method WAComponent>>renderContentOn: as follows and commit your changes.

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

Now when you click on the links you will see the counter increment or decrement.

A simple counter with increment and decrement actions

Copyright © 26 September 2017 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.