Aida and input field validation
By Hilaire on Wednesday 18 February 2015, 13:09 - Permalink
For a new project, I have been looking for a Smalltalk web server to design a web application. I have been previously exploring Seaside+Magritte and more recently - a couple of hours ago - I took a fresh look at Aida. And to say the true, I have been impressed by how it can be simple and yet effective to handle my problem. Let's take a look at its field validation approach.
I experimented the Aida validation approach with its AddressBook tutorial, and modified it as follow:
DemoAddressApp>>viewEdit | e field | e := WebElement new. e addTextH1: 'Add/Edit the address'. self inError ifTrue: [e cell add: self errorReport. e newRow]. [...] e cell addText: 'Email:'; addBreak. field := e cell addInputFieldAspect: #email for: self observee. field onChangePost; validIfTrue: [ :value | value includes: $@]; errorText: 'Cela ne ressemble pas à un email'. e newCell add: field errorElement. [...]
Then, the default action of the
editView need to be modified
ADemoAddressApp>>actionEdit self context form isValid ifFalse: [self showError: self context form collectErrorTexts. ^ self redirectToView: #edit]. self observee changeToPreferredUrl. self redirectToView: #main
It is definitely not a Saturn V class rocket approach, but more something like a manageable Ariane V class rocket.