File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes optionsCollection issue with DynaValidatorForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "optionsCollection issue with DynaValidatorForm" Watch "optionsCollection issue with DynaValidatorForm" New topic

optionsCollection issue with DynaValidatorForm

Scott Updike
Ranch Hand

Joined: Feb 16, 2006
Posts: 92
I have a jsp page that has a combo box that is populated with a optionsCollection tag. The collection is a bean property that is an ArrayList of objects. For example, I have the following jsp snippet:

..where customerto is a bean that contains an ArrayList of termcode objects (termcodes) that have the String property of termcode.

Everything displays fine, but if the form fails validation, the collection is not being saved to the DynaValidatorForm bean and hence generates an error that states:

Here's how I have it defined in my struts-config.xml file:

Does anyone have any advice for me on how to get the DynaValidatorForm bean to accept a collection and pass it to my jsp error page?

I hope I stated my question clearly!

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It looks like the problem here is that there is a discrepancy between how you've defined your form bean and the data you've actually populated it with. You've defined termCodes as a string array, yet you've populated it with an ArrayList. To fix this, just change the definition:

[ September 16, 2007: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
I agree. Here's the link:
subject: optionsCollection issue with DynaValidatorForm
It's not a secret anymore!