Hi friends, Iam new to struts, but presently working on it, how should display error messages by making the labels of the respective textboxs in a different color(for ex: say if First Name invalid then First Name in red) if possible plz do provide an example.
posted 11 years ago
Struts does not specifically provide any error handling for each and every form field like text box labels in your case. What it provides is a framework for error handling using the struts ActionError. You can add many such ActionError objects to an ActionErrors object in the Action class. Using saveErrors(request, ActionErrors) method provided in the action class, you can save the ActionErrors in the request. This can be accessed on the jsp by including the tag <html:errors/>. This will display all the errors that have been added via ActionErrors. For your specific problem you might have to employ some logic to each of the form field labels and play on with their fonts. So, in the form bean you will probably need to keep the status of error for each of the form fields and then use that information to display the label in relevant font. [ December 02, 2004: Message edited by: Dharmanand Singh ]