You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zimmer, Robin (SSABSA)" <ro...@ssabsa.sa.gov.au> on 2002/07/26 02:33:00 UTC

multibox validation and collections

> Dear all,
> I have a multibox that I am using within a table. The individual check box
> is supposed to signify the selection of a row in the table. The table is
> populated by a collection. Plus the form bean that holds the collection is
> on the request.
> 
> 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???
> 
> Many thanks, Rob.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: multibox validation and collections

Posted by Jonathan Fuerth <fu...@sqlpower.ca>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>