struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Maurer <>
Subject RE: List-backed properties
Date Thu, 06 Mar 2003 14:10:13 GMT
Hi hans !

As my best practice, the thing missing is following : 

in any action form is a reset method per subclassing action from.
1st-class use of reset for me is to set every action form instance
variable to some initialising state. so what is the initialising state
of an array list? exactly, first of all the number of the elements you
want to fill in.

how do we know how many of these elments will there be? because we
queried our database before and remembered the count of records in our
action class. with this knowledge, call reset with the count - but hold
- there is no parameter to give to reset!

So i made in every action from class my own reset method called
myReset(int prepare_for_count) - 2 advantages : 
1.)as reset() is called always by framework(after each new request), i
can´t manage session state in action form with this solution. exception
to this case is well known checkbox problem. so i am in full charge of
when and how myReset() is called.
2.)i can inform myReset of prepare_for_count value.

so inside myReset(int prepare_for_count){ //there will be something like

	values = new ArraList();

after that call, i fill in data from my result set in action form.

1 disadvantage : i have to take care of THAT i call myReset().

Hope that helps.... Jörg

-----Original Message-----
From: Johann Uhrmann []
Sent: Donnerstag, 06. März 2003 10:47
To: Struts Users Mailing List
Subject: List-backed properties

Hello all,

I am a little bit confused about an example for list-backed properties:

The documentation at
contains the following example in section 4.3.2:

public FooForm extends ActionForm {

     private final List values = new ArrayList();

     public void setValue(int key, Object value) {
         values.set(key, value);

     public Object getValue(int key) {
         return values.get(key);

As "values" is initialized as empty ArrayList, any call to values.set 
causes an IndexOutOfBoundException to be thrown.
(see also:

Therefore, I cannot imagine how that example could ever work.
Could someone please explain me that discrepancy?

Thanks in advance,


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

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

View raw message