I am migrating from JSP+Valang+...+SpringMVC to Wicket and am also still evaluting it. So far so good until I saw this instance about using Form Validator to validate two related form fields.
Problem (p81-82, book Enjoy Web Development with Wicket, PDF version only): Suppose a postage calculation form has two fields that accept weight and patron discount code. For a particular patron p1, you will never ship a package that is weighted more than 50kg. Here is the code from the book: public class LightValidator extends AbstractFormValidator { private TextField weight; private TextField patronCode; public LightValidator(TextField weight, TextField patronCode) { this.weight = weight; this.patronCode = patronCode; } public FormComponent[] getDependentFormComponents() { return new FormComponent[] { weight, patronCode }; } public void validate(Form form) { String patronCodeEntered = (String) patronCode.getConvertedInput(); if (patronCodeEntered != null) { if (patronCodeEntered.equals("p1") && ((Integer) weight.getConvertedInput()).intValue() > 50) { error(weight); } } } } I have the bad feeling about this way of validation 1. It is too much coding. Anybody used Valang in Spring Module? By using Valang, the validation code is much clean and a lot fewer and you dont need to create a class simply for this simple validation. 2. Valang covers both client AND server-side validation. Please note that client-side validation is equally important as server-side's. I feel it is a must for web apps in terms of user experience. 3. In Valang + Spring MVD, you have all the validation code for a form in one place in stark contrast to spreading it in "controller" code as in Wicket and mixing validation code with visual manipulation code. Valang's way is much easier to understand and management. So in terms of elegance, productivity, management, ..., I am not sure Wicket's is right. Can Wicket provide a better solution? I would like to share my concern regarding the Wicket's WebPage, where you put a form's code for some visual aspects, validation, ajax, etc. in one place. A big object. I feel it is too ambitious and it looks like spaghetti code and mixes concerns/modules in one place. Comment? I am very new to Wicket and don't know the best ways of using Wicket. I love to hear from expereinced users/guru here. Thanks for your input! Warm regards, David ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]