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.
SampleLoginComponent>>initialize
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
.