commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tal Lev-Ami <...@trivnet.com>
Subject [validator] Extending forms and fields
Date Mon, 30 Sep 2002 10:42:48 GMT
Context:
We are developing a complex system using Struts and EJBs. We use the
validator package both for UI purposes and for our EJB syntactic validation.
We are using the same validation XML for the UI and EJB with different
validation-rules.

Problem:
There are a lot of fields to be validated and the same field can appear in
multiple forms. This create "code" duplication when the field definitions
must be redeclared for each form. In some cases two forms are almost
identical with difference of a field or two. Another trigger to this problem
is the fact that the same functionality can be accessed both through the UI
and directly through the EJB API.

Solution:
1. Add a new attribute to the form tag - extends. The form referenced in the
extends attribute is considered the "super-form" of the new form. This is
very similar to the way that a form in a formset with a specific locale can
extend a form in the default formset. Locale search order is kept when
searching the extended form.
2. Add a new attribute to the field tag - uses. The format of the attribute
is <formname>.<fieldname> A field that specifies this attribute is replaced
with the field called "fieldname" in the form called "formname". Locale
search order is kept.

Implementation:
Extends the ValidationResources.processForms() to rebuild all the forms
taking the uses and extend fields into account.

Open Issues:
How can error handling be performed inside the validator package (e.g. the
form or field extended do not exist)?

If anybody is interested in this, I can post a patch with the new feature.
I would appreciate any comments for a better semantics or implementation.

Tal Lev-Ami
Trivnet Ltd.

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message