Can anyone tell me what object is the html:error tag looking at please? I am new to struts, I know that the validate() method in actionform would throws errors and the jsp will populate the original data with a list of errors displayed on the top of the page...
But how can I add my own exception to that error list please? Is it possible? Do I need to populate the form myself? or is there a way which I can throw exceptions/errors to the jsp page just like how validate() method does it??
Joined: Feb 15, 2005
The <html:errors> tag uses the ActionErrors class, which contains a collection of ActionError (V1.1) or ActionMessage (V1.2 & above) objects. To add a new message, just use the add() method of this object. You place this object in request scope by using the saveErrors() method of the Action class (Which is your action's superclass). If you're setting an error condition in the validate() method of an ActionForm, just make sure you've added an ActionError to the ActionErrors object before it is returned from the method.