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
[ self chooseCheese.
self confirmCheese ] whileFalse.
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.
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,
^ self confirm: 'Is ' , cheese , 'your favorite Cheese?'
Last but not least we display the choice of the user using
self inform: 'Your favorite is ' , cheese , '.'
As simple as that. And yes, the back button still works.