struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Linus Nikander" <>
Subject Re: Is this really the best way to handle this problem
Date Tue, 15 Jul 2003 21:14:59 GMT
First off, thank you for the reply.

As you point out both solutions that you suggest have a certain hackishness
over them it would be nice to avoid. As displaying data from a DB-table,
allowing that data to be edited (en masse, not one record at a time), must
be a pretty common task, doesn't anyone have a more elegant solution when
using struts ?


"John M. Corro" <> wrote in message
> I've seen two ways of dealing w/ this problem, both of which I see as
> in nature.
> Solution A:
> In your getters/setters you implement the following code
> public MyCustomBean getMyCustomBean(int index) {
>    while(index >= myCustomBeanList.size()) {
>       myCustomBeanList.add(new MyCustomBean());
>    }
>    return (MyCustomBean)myCustomBeanList.get(index);
> }
> In that way you'll never encounter the common IndexOutOfBoundsException.
> problem here is that you tend to use alot of hidden fields in your UI to
> the data back into the dynamically created beans.
> Solution B:
> In your reset() method you repopulate your internal Collection of beans.
> problem w/ this approach is that often times you have a separate Action
> prepopulates your ActionForm.  This provides for good separation - the
> is a retriever of a data (nothing more) and the ActionForm is merely a
> for data (nothing more).  With this approach your ActionForm suddenly
> becoming more intelligent than it really should be.  Now it's aware of how
> populate itself...not a good thing IMO.
> I'd be very interested in hearing other solutions to this problem as I
> both of the above solutions cumbersome and hackish and would love to stop
> them.
> >I've been struggling with a problem similar to the one described (and
> >solved) at
> >

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message