cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <>
Subject Re: CFORMS - Performing a Form level validation
Date Tue, 31 May 2005 19:07:37 GMT
Messing, Elad wrote:

> Hi all
>         I tried looking for a "definition" text on the preferred way 
> of performing a Form level validation.
>         What I mean is that I need to perform validation that is 
> relevant to the Form -not to specific widget. I.E. - I have a form 
> with 2 widgets, and I need to check that either 1 of them has a value 
> in it.
>         So - I know I can have a validation in one of the widgets, and 
> in it write some javascript to check the other as well, and then 
> output the error to a "fi:validation-errors" tag - to show it in a 
> central place.
>         But this seems like a work around rather than a real plan..

You can add a <fd:validation> on any widget, including a form. But not 
every widget can hold validation errors, as not every widget has a 
visual representation.

So validation on non-visual widgets should set validation errors on one 
of their child widgets. Another option if there's no suitable widget to 
attach the error to is to add the error text to a <fd:message> widget.

For more details, see the javadocs of 
o.a.c.forms.validation.WidgetValidator and form1.xml in the samples: the 
"contacts" repeater has a validator that checks row uniqueness and sets 
an error on the duplicate rows.

>         A second and related question will be - In my form with 2 
> widgets, each one of them has its own validation. So - they are not 
> required, but in case the user enters something into them, It should 
> be validated. After this validation, I will need to have the "Form 
> Level" validation I mentioned above.

That should occur automatically.

Hope this helps,

Sylvain Wallez                        Anyware Technologies  
Apache Software Foundation Member     Research & Technology Director

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message