Sylvain Wallez wrote:
> Bruno Dumon wrote:
> 
>> In the javascript validation (or in any validation for that matter), if
>> you return false, you should also set a validation error on the widget
>> to which the validator belongs, or a child/descendant widget of that
>> widget (e.g. in case the validator belongs to a form or repeater).
>>
>> Have a look at the source of the samples for how to do this.
>>   
> 
> 
> Yep.
> 
> Note that in 2.1.8 (real soon now!), the javascript validator has been
> extended so that it can now, along with booleans, return a String,
> ValidationError or I18Message. In that case, the error is set on the
> current widget and the validation fails.

Sylvain,

I happened to be doing something similar at the time, so I looked at the
code. Looking at:

http://svn.apache.org/repos/asf/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java

Method validate(Widget widget), I notice:

        if (result instanceof Boolean) {
            return ((Boolean)result).booleanValue();
        }

        if (result instanceof ValidationError) {
            // Set the validation error on the widget

((ValidationErrorAware)widget).setValidationError((ValidationError)result);
        }

        if (result instanceof String) {
            // Set a non-i18n error on the current widget
            ((ValidationErrorAware)widget).setValidationError(new
ValidationError((String)result, false));
            return false;
        }

The middle one of these if statements doesn't return anything, and will
thus throw a RuntimeException at the end of the method. Is this correct?

Regards, Upayavira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]