It should be straight forward - there are only two things you need to do:

1) Sore you ActionMessages under the standard struts "error" key - which if
your using <html:errors> (or <html:messages>) you probably are already doing
anyway. If you're doing your validation in the ActionForm's validate method
then this happens automatically or if you're doing it in your Action then
you can use the the saveErrors(request, errors) method.

2) You need to store the messages using the same "property" name that
your're using on the Struts html tags - so if you have <html:text
property="custno"/> in the jsp, then you need to add the error message to
ActionMessages using the same property name:

    ActionMessages errors = new ActionMessages();
    if (myForm.getCustno() == null) {
         errors.add("custno", new ActionMessage("custno.missing"));
    }

Obviously you also need to set up your error styles in CSS and specify the
errorStyleClass on the <html> tags.

Niall

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
Sent: Monday, October 17, 2005 3:26 PM


> Hi there,
>
> I would like to make use of the errorStyleClass functionality with
> validation errors that I create in my action class using ActionMessages. I
> guess there must be a way of letting the ActionMessage object know which
UI
> field it is relating to.
>
> Has anyone managed to do this without creating custom validation
controlled
> by validation.xml?
>
> Paul



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

Reply via email to