cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <>
Subject Generalizing validation to non-valued widgets (was Re: [cforms] Optionally required fields)
Date Thu, 08 Jan 2004 15:46:06 GMT
Vadim Gritsenko wrote:

>>> PS Antonio, can you attach not a Javascript, but custom Java 
>>> validator to the form?
>> I think this is posible, by calling a java function inside of a 
>> javascript function.
> No, I mean without Flowscript, and I mean not a Javascript form object 
> but real Form class.
> org.apache.cocoon.woody.formmodel.Form does not seem to have any 
> setters/getters for validators, so I presume that's not possible.

Yep. I added the "form.validator" thing to allow application-level 
validation. By application-level, I mean a validation that not only 
involves several widgets, but also that needs to access application data 
which is not available in the form. But I'm not very happy with this and 
would prefer it to be handled at the Java API level.

Now I think that every widget should be able to have validators. Some 
use cases:
- on a form, to perform some inter-field validations, and even 
application-level validation if the means to access application data is 
given to the validator.
- on a repeater, to check e.g. uniqueness of some values among rows
- on a group (i.e. "class", "struct", etc) where some validation between 
the various widgets of the group may be wanted (actually, a form is a group)

The current ValidationRule interface is not suited for this, as it is 
really tied to widgets that have a value, which neither form nor 
repeater have.

So my idea is to introduce a generalized "WidgetValidator" with a single 
"validate(Widget w, FormContext ctx)" method. The current ValidationRule 
implementations we have today can then simply become subclasses of a 
"FieldValidator" abstract class.

We also have to see how validators can have knowledge of the surrounding 
application environment to perform application-level validation. A 
discussion between Marc and myself a while ago came to the conclusion 
that we may use pseudo-fields in a form as value holders, as it would 
make the contract between the form and the application more visible than 
by adding attributes to the Form object.

What do you think?


Sylvain Wallez                                  Anyware Technologies 
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -

View raw message