<wd:repeater id="contacts">
<wd:validation>
<wd:javascript>
...
for (var i = 0; i < widget.size; i++) {Which properties are available here? Obviously widget, but maybe also form? This would be cool as I can replace the XReporter asserts that I have problems with.
...
row.getWidget("firstname").setValidationError(new Packages.org.apache.cocoon.woody.datatype.ValidationError("Duplicate contact name", false));
Must we specify Packages.org.apache.cocoon.woody.datatype.ValidationError() ?? It seems to be to much typing. What about just setValidationError(String [, more parameters])? Do we loose flexibility? At the moment there is only o.a.c.w.validation.ValidationError and the deprecated extending o.a.c.w.datatype.ValidationError.
BTW, shouldn't the sample create a non-deprecated ValidationError?
...
</wd:javascript>
</wd:validation>Joerg
On 04.02.2004 18:50, Sylvain Wallez wrote:
Hi peeps,
I finally managed to finish the new style of validation we discussed a while ago.
This new validation allows *any* widget to have a validator. The immediate effect is that <wd:validator> is now outside of <wd:datatype> since not all widgets have a datatype.
The validator interface has also changed, since not all widgets are capable of displaying a validation error. A validator now has the responsibility, if validation fails, to set a ValidationError on the validated widget itself or one of its children. Widgets that accept a validation error implement the ValidationErrorAware interface.
The existing validators have been wrapped with an adapter and are therefore still supported, although deprecated.
I updated the form1 definition in the samples: moved the validation outside the datatype, and added a validation on the repeater that checks if contact names are disctinct among the different rows. This sample uses a new JavaScriptValidator that allows validator to be written as a JS snippet.
Enjoy, Sylvain
