STRUTS: Iterating over a collection of ActionErrors
posted 11 years ago
I currently have a JavaBean that maintains a collection of Strut's ActionErrors objects, and another collection of Strings. There is absolutely no problem in using the iterate tag to retrieve the Strings and displaying them on the screen. The tough problem is retrieving the ActionErrors and showing them. The following is how I coded the JSP:
Does the method GCIItemErrors.getErrors() return a "Collection of ActionErrors objects" or a singe "ActionErrors" object? Note the return type of the method should be one of the following (as expected by logic iterate tag): - Iterator - Collection - Map (whose values are to be iterated over) - array
If getErrors() directly returns you the "ActionErrors" object, then you do not need the inner iterate tag. In this case you might need to put your "ActionErrors" object in request scope so that the <html:errors> tag finds it.