If I understand correctly this is due to the fact that the collection is not anymore in the request, right? If I create a constructor for the ActionForm with some static LabelValueBeans the validation works just fine.
Any ideas how to proceed?
P.S: Yes, I know accessing DB directly from the action is a bad thing. I will learn to use Hibernate as soon as I have some spare time
Joined: Jun 18, 2004
The "No collection found" message comes from the JSP. It means that the collection holding all available checkboxes is empty. But, how did it become empty ? It becomes empty by the validate method. So, when the validate method returns ActionErrors, the JSP is re-displayed. But this time, the collection of available checkboxes is empty or null and you'll see the "No collection found" error message.
solution: When the validate method creates ActionError objects, make sure you populate the collection of available checkboxes before the validate method exits.
Joined: Feb 15, 2005
Frank's solution will work, but if you're going to re-create the possible options, I prefer to do it by overriding the reset() method in the Actionform and placing the logic there. This always gets called before validate() and it seems cleaner to put the rebuild logic there and save the validate() method only for validation logic.
There is also another solution: If you think about it, the possible options are probably the same, no matter who is calling the page, right? If this is the case, why not just build this array of options once and store it in application scope? In my opinion, the best solution would be to modify the logic in your action to check for the existence of the array like this: