Re: errorStyleClass with ActionMessages
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 (or ) 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 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 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]
Re: errorStyleClass with ActionMessages
At 3:26 PM +0100 10/17/05, [EMAIL PROTECTED] wrote: 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? When you add an ActionMessage object to an ActionMessages collection, you must specify the "property" with which the message associates. This string should be exactly the value in the "property" attribute of your form element in the JSP. Hope that helps, Joe -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
errorStyleClass with ActionMessages
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]