Dynamic Web Development with Seaside

12.6.2Behavioral Decorations

Validation. A WAValidationDecoration validates its component form data when the component returns using WAComponent>>answer or WAComponent>>answer:. This decoration can be added to a component via the method WAValidationDecoration>>validateWith: as shown below.

super initialize.
form := WAFormDecoration new buttons: self buttons.
self addDecoration: form.
self validateWith: [ :answer | answer validate ].
self addMessage: 'Please enter the following information'.

If the component returns via answer:, the answer: argument is passed to the validate block. If the component returns using answer the sender of answer is passed to the validate block.

Talk about WADelegation and WAAnswerHandler.

Accessing the component. To access the component when you have only a reference to its decoration you can use the message WADecoration>>decoratedComponent.

Copyright © 20 April 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.