• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

STRUTS: Iterating over a collection of ActionErrors

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

<logic:iterate name="catalogPublishedResults" property="notPublishedItems" type="com.mercador.ejb.session.GCIProduct.GCIItemErrors" id="notPublishedItemReference">

<bean:write name="notPublishedItemReference" property="GTIN" />,

<logic:iterate name="notPublishedItemReference" property="errors" type="org.apache.struts.action.ActionError" id="notPublishedItemReferenceErrors">
(<i><html:errors name="notPublishedItemReferenceErrors" /></i>
</logic:iterate>

</logic:iterate>

This is the error message I get from webLogic when accessing the page: javax.servlet.jsp.JspException: Cannot create iterator for this collection

Any help is much appreciated.

Regards,
Filipe Pomar
 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Sheldon Fernandes
reply
    Bookmark Topic Watch Topic
  • New Topic