From: Ken K. <kk...@ig...> - 2002-06-02 16:24:02
|
First let me say that at ign.com we're been using our own validation framework for over a year. Now I'm surveying what others have done. Your framework looks very well done. * * * If you leave the age field blank, you get: java.lang.NullPointerException at org.formproc.example.IsIntRule.validate(Unknown Source) at org.formproc.validation.RuleValidator.validate(Unknown Source) at org.formproc.validation.ValidatorGroup.validate(Unknown Source) at org.formproc.Form.validate(Unknown Source) at org.formproc.Form.process(Unknown Source) at org.formproc.Form.process(Unknown Source) at org.formproc.Form.process(Unknown Source) at org.formproc.servlet.HttpForm.process(Unknown Source) <shared-validator name="age"> <validator type="group"> <validator type="rule"> <rule>org.formproc.example.IsIntRule</rule> <error>Valid number required</error> <error lang="fr">L'âge valide a exigé.</error> </validator> <validator type="expression"> <pattern>[1-9][0-9]*</pattern> <error>Age must be 1 or greater</error> </validator> </validator> </shared-validator> Should the expression validator be listed before the IsIntRule? Since the age field isn't marked required, why do the validators get applied when the field is blank? * * * In the example, you decided to hold the form's state in a User in the session. This doesn't seem correct to me. It seems preferable to redisplay the invalid form w/ the invalid strings. After all, you're validating from the HttpRequest via HttpForm. So would the code be something like this? Age: <% if (! elementResults.isValid("age")) { >% <input type="text" name="age" value="<%= req.getParameter("age") %>"> <font color="#ff0000"> <% else { %> <input type="text" name="age" value="<%= user.getAge() %>"> <font> <% } %> <%= form.getMessage("age", locale) %> </font> * * * formManager.configure(form); To avoid repeated parsing of the XML, should the formManager be instantiated once per app? * * * > BTW: Have you tried the FormProcService which is a TurbineService > implementation yet? I haven't tested it yet so I would be interested if > anyone who does use Turbine on a regular basis would take a look at it. > It is in the CVS in the turbine-service module. Turbine 2.1? Did you program this service? Is there any documentation? Thx. -Ken |