I've done around 3 different web applications now, and all 3 have handled
JSP form input & field validation in different ways - so the question I pose to you all is, what is the best way?
Given these constraints:
1) clean & simple design
2) easy linking between the JSP form fields and the bean fields (loading)
3) easy way to do validation
I would guess that some degree of reflection would be used to automate the field processing.
So here's my current take on things:
Common JavaBean, but with the addition of a set of validation methods (get/set/validate) that take in
String input and validate it against the field type. I'm planning on naming the fields in the JSP exactly as the field name in the bean, although that might run into problems if the input uses more than one bean and they have the same fieldnames. Once the form is submitted, go through all the input parameters calling the validate & set methods for the appropriate fields.
how's that sound?