F.Y.I. I resolved my problem by setting the 'input' value of the
struts-config action mapping to the action that initialised the form bean
(then forwards to the jsp) rather than the jsp directly. 
PS. Thanks for your response. 

-----Original Message-----
From: Jonathan Fuerth [mailto:[EMAIL PROTECTED]]
Sent: Saturday, 27 July 2002 12:09 AM
To: Struts Users Mailing List
Subject: Re: multibox validation and collections


On Fri, Jul 26, 2002 at 10:03:00AM +0930, Zimmer, Robin (SSABSA) wrote:
> I have overrridden the validate method of the form bean to ensure
> that at least one checkbox is selected. If not and ActionError is
> created.
> 
> The problem is that I now get a collection not found excpetion when
> the jsp is envoked. I solved this by making the form bean a session
> form bean, but is this the only way? If so, does anyone have any
> suggestions as to how to manage the formbeans on the session and are
> they serializable???

If your form's validate method returns errors, then the Struts
controller servlet immediately forwards the user to the page specified
in the input="xxxpage.foo" attribute for the current action in
struts-config.xml.  Your own action class is not invoked this time, so
any setup it might have done in request scope for your JSP (such as
populating lists for your dropdowns) is not performed.

Putting your setup in session scope will solve that problem, but
create another: you'll end up with a lot of JVM memory being pinned
down for lists that users don't really need anymore.. and trying to
come up with logic to clear out old lists from the session when
they're no longer needed is a losing battle. :)

I've tried to make my JSPs independent of action and form setup
(because of the way form validation works). A good clean way to do
that is to put getListOfXXX() methods on your business objects where
needed, and use those methods directly in the JSP when you need
Collections for <html:options> and <logic:iterate>.

I hope that helps, and I hope I answered your question. :)

PS: ActionForm is serializable, but I still wouldn't recommend keeping
    lots of forms in session scope because of the memory issues.
    Check out http://jakarta.apache.org/struts/api/index.html for 
    everything you ever wanted to know about the struts classes (that's
    where I went to double-check that ActionForm is serializable).

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to