[Webwork-user] WebWork 0.7 - Struts example, input validation
Brought to you by:
baldree,
rickardoberg
From: Rickard <ri...@jb...> - 2000-12-11 13:43:56
|
WebWork 0.7 is available in CVS I have just uploaded the last pieces of WebWork 0.7 to CVS (SourceForge FTP is full so I will do the zip upload later). There is a new ValidationEditorSupport base class available. This is useful for creating PropertyEditors that perform validation of input parameters, which can now be *completely externalized from the Actions*. This is a very important feature. This means that your Actions does not have to deal with validating the input, even if the input is strings that should simply conform to some given pattern. Instead you should create a BeanInfo object that describes what JavaBean PropertyEditors should be used for each attribute, and then the standard JavaBeans API will be used to interact with them for validation. If something goes wrong you can use the ValidationAware interface to get the exceptions, and as outlined in earlier post the ActionFormSupport base action does this so that the error messages are available to be used in, for example, generic JSP controls. This is also important if you want to reuse Actions in different projects, where the only difference between the projects are the requirements on the input parameters (not uncommon scenario). Then, all you have to do is make a new set of PropertyEditors, and make sure the BeanInfo about the Action uses them. No changes to the Actions themselves would be needed. In addition, the recent Struts example from JavaWorld has been fully converted to WebWork, and now uses the above validation techniques. The code is *very* clean and simple, and truly shows how WebWork makes it effortless to create web apps. Thor (the original author) is in CC of this post, and it would be great if you could comment on what you think about the adaptation from an implementation/design point of view. regards, Rickard -- Rickard Öberg Email: ri...@jb... |