struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johann Uhrmann <johann.uhrm...@xpecto.com>
Subject List-backed properties
Date Thu, 06 Mar 2003 09:46:31 GMT
Hello all,

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

The documentation at 
http://jakarta.apache.org/struts/userGuide/building_controller.html
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: 
http://java.sun.com/j2se/1.4.1/docs/api/java/util/ArrayList.html#set(int,java.lang.Object)

  )

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

Thanks in advance,

Hans


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message