Jakarta commons validator question

E

eddiethomas

I have been using the Jakarta Commons Validator (without Struts) for a
project at work and I think its awesome. Here's my problem. I have
multiple "forms" where the fields are disributed in different pages. So
for example, in "form1" the firstName field is in page 1. In "form2"
the first name field is in page 5. We can validate this by creating two
<form> elements in the validation.xml file and changing the page
attribute in the <field> tag.

Doesn't this tie the actual logic of validating the fields to the
presentation/view? This pretty much means that if I move fields around
from one page to the other I am forced to duplicate the <form> tag with
a new mapping and change the page attribute.

Instead of doing that, why don't we create another constructor for the
Validator class that takes a List of fields to be validated. That way
the "action" (or the servlet that proceses the request) can read the
fields that were submitted from the request and validate only those
fields. The advantage of this approach would be, everytime fields are
moved around, our validation.xml file does not need to change. We just
focus on creating the JSP (or whatever) page and not worry about the
validations. Of course, we do need to ensure that the request paramater
names match the field name. The disadvantage of this approach is that,
we are only validating those fields that are being submitted. So when
you submit page 3, only page 3 is validated, not page 1 and 2.

I'm willing to contribute to the commons source code but before I do
that, I wanted to know if my thought process is flawed or if I am
missing something. I looked at the TODO list in the Commons Validator
and didn't find anything that matches what I am looking for.
Thanks,
Eddie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top