On Fri, 2004-05-28 at 11:24, Upayavira wrote:
> Joerg Heinicke wrote:
> 
> > On 28.05.2004 01:13, Benoit Deshaies wrote:
> >
> >> re: adding form-level validation error messageS.
> >>
> >> This is a feature I would use as well. In our applications, we often
> >> display the list of errors at the top of the form and then each field
> >> in error is styled in red and the label gets an *.
> >>
> >> This is something Struts offers *wink* *wink*.  See <html:errors> at
> >> http://jakarta.apache.org/struts/userGuide/struts-html.html#errors
> >
> >
> > That's what fi:validation-errors is about.
> 
> Great. But how do you set that using Java code?

Not. It only collects the validation errors of other widgets, in order
to show them together at one location. And it does that by scanning over
the XML, not over the original widget tree. This makes that if you would
forget to include a widget, you wouldn't see its error either.

>  E.g. wanting to set it 
> to say "Your user/pass was incorrect"?

Validation errors can only be set on widgets implementing the
ValidationErrorAware interface, see the table on
http://cocoon.apache.org/2.1/userdocs/forms/validation.html

This doesn't help you for your case where you need to show a validation
error that is global to the form as a whole.

Alternatively, there is the fd:messages widget. You can add messages to
it by calling addMessage() on it. I'm not sure if this is a good
solution, since those messages are not specifically recognized as being
validation errors, and so this wouldn't work together with
fi:validation-errors. Maybe the best would be to allow adding validation
errors (multiple ones) on the form itself. fi:validation-errors would
then better be replaced with a ft:validation-errors (which can crawl the
widget tree), since otherwise it wouldn't find the errors attached to
the form.

WDYT?

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED]                          [EMAIL PROTECTED]


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

Reply via email to