Task

Complex, multi-page workflows can be expressed in Seaside with a single method. Unlike servlet models which require a separate handler for each page or request, Seaside models an entire user session as a continuous piece of code, with natural, linear control flow.

What's your favorite Cheese?

This example can be implemented by subclassing WATask and implementing the hook method #go. We store the users choice in an instance variable named cheese.

go
[ self chooseCheese.
self confirmCheese ] whileFalse.
self informCheese

To let the user choose from a famous Swiss cheese we use the conveninace method #chooseFrom:caption: which returns the chosen element form a collection or nil if the user canceled the dialog. In this case we simply ask again.

chooseCheese
cheese := self
chooseFrom: #( 'Greyerzer' 'Tilsiter' 'Sbrinz' )
caption: 'What''s your favorite Cheese?'.
cheese isNil ifTrue: [ self chooseCheese ]

Then we let the user confirm his choice. #confirm: answers a boolean, true or false:

confirmCheese
^ self confirm: 'Is ' , cheese , 'your favorite Cheese?'

Last but not least we display the choice of the user using #inform:.

informCheese
self inform: 'Your favorite is ' , cheese , '.'

As simple as that. And yes, the back button still works.