Dynamic Web Development with Seaside

2.4.4Rendering a Counter

Now we can focus on Seaside specific methods. We will define the method renderContentOn: to display the counter as a heading. When Seaside needs to display a component in the web browser, it calls the renderContentOn: method of the component, which allows the component to decide how it should be rendered.

Add a new method category called rendering, and add the method definition

WebCounter>>renderContentOn: html
html heading: count

We want to display the value of the variable count by using an HTML heading tag. In Seaside, rather than having to write the HTML directly, we simply send the message heading: to the html object that we were given as an argument.

As we will see later, when we have completed our application, this method will give us output as shown in Figure 10.

A simple counter

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.