Having had a look at struts for few weeks now, I have some thoughts based on other work I've done and what I'd like to see/do implemented. Just to start with, I do like it. It'll make development cleaner and easier. I would have done something similar based on Cold Fusion's fusebox model probably. The validation method in ActionForm.validate seems to me to being too simple. I'm used to JavaScript validation that is fairly similar (see attached html file). I do notice that there is some mention of this in the TODO list. The main problem I see so far with validate is how it will work for mulitpage forms. The only way I can see that it'd work is by having a hidden field (or form submit value that would specify the page number and an if statement in the validate method that would check just the required values. This would tie the validate too closely to the HTML page. If you look at the example I've attached, you'll see that there are references to the pages in MultipageForm and MultipageAction, as well as validation that is tied to the pages. (The code could be cleaner, eg. more messages from the .properties file, better error checking, and cleaning out unused beans, formatting of the code ;-) I could write the code so it checks that a parameter is specified, but this will cause problems with check boxes and multiple select. Also, I couldn't work out how to get the request attributes to be sticky between the next and previous pages (think CGI.pm and it's param() functions). It's probably something to do with the response, but I don't have the docs handy. What I'd like to see is better use of the Bean style, where we use PropertyVetoException and similar. It does mean writing a more stubborn bean container. But it'll be useful when it comes to using Beans developed for instant graphical interfaces. Since all my work has been back end work, I've only just got into Beans now after a long time in Servlets, EJB and Java 1.0 AWT programming. Have fun ...Title: Form Validation
Not required/not validated phone number: Not required/validated: Text field: 4 digit number (credit crad/postcode) Phone number: Email: Credit Month: Credit Year: |
-- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html