[aida] Post Tutorial comments - validation
Janko Mivšek
janko.mivsek at eranova.si
Wed Apr 20 22:49:23 CEST 2011
Hi Elliot,
Let me split this thread in two branches, first one about validation:
On 18. 04. 2011 06:54, Elliot Finley wrote:
> 2011/4/11 Janko Mivšek <janko.mivsek na eranova.si>:
>>> #1) Where would I hook in data validations?
>>
>> See the WebDemoApp>>ajaxValidationExample :
>> ...
>> field := e cell addInputFieldAspect: #year for: self size: 4.
>> field
>> onChangePost;
>> validIfTrue: [:value | value asInteger = Date today year];
>> errorText: 'Wrong!'.
>> e newCell add: field errorElement.
>>
>> So, #validIfTrue: aBlock is the main thing for making a validation of
>> your data. If this block doesn’t pass, submitting of a whole form is
>> blocked. Only until all fields on form are valid, submitting will succeed.
>>
>> What you see in above demo is an additional ajaxified validation and
>> error reporting immediately after data entry.
>
> how would I do a validation based on another form field. For example
> if I had a scheduling application and I had a startDate and endDate.
> I would want to validate that both dates were in the future and I
> would want to validate that startDate < endDate.
If you do Ajax single field posting as in above example, you have value
of first field already saved into domain object, so you can use it in
validation of second field, something like:
field
...
validIfTrue: [:endDate | self observee startDate < endDate ]
...
Best regards
Janko
--
Janko Mivšek
Aida/Web
Smalltalk Web Application Server
http://www.aidaweb.si
More information about the Aida
mailing list