You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Tal Lev-Ami <tl...@trivnet.com> on 2002/09/30 12:42:48 UTC

[validator] Extending forms and fields

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>