Rick,

You should be able to do this in the indexed setter, something like this....

protected String[] myStringArray;

public void setMyString(int index, String myString) {

          // Allocate the array
          if  (myStringArray == null) {
               myStringArray = new String[index + 1];
          }

          // Grow the array
          if (index >= myStringArray.length) {
               String[] newMyStringArray = new String[index + 1];
               System.arraycopy(myStringArray, 0, newMyStringArray , 0,
myStringArray.length);
               myStringArray = newMyStringArray ;
          }

          // Set the indexed property
          myStringArray[index] = myString;

}

Alternatively, just use a LazyValidatorForm and define the String[] as a
property in the struts-config and it will do this for you.

Niall

----- Original Message ----- 
From: "Rick Reumann" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, October 12, 2004 4:14 PM
Subject: Can lazyList help out for indexed arrays in ActionForm?


> I have a situation where I need to use fields on form that are indexed...
>
> tier[0], tier[1], etc. (possibly more)
>
> Is there a way I could use a LazyList implmentation to grow this if the
>   form property is defined as String[]? (I know how to grow a List in
> the reset using LazList but not sure of an easy way to do this with an
> array unless I create my own setters that will grow the array and use
> those different setters in the form ie. tierIndexed[0] etc )
>
> TIA for any help. (If I hardcode a size in the reset for the array
> things are fine, but of course I want to avoid just declaring some
> arbitrary size).
>
> I've looked over Niall's wiki but still stumped on this since that wiki
> is dealing with dyna implementations
> http://wiki.apache.org/struts/StrutsCatalogLazyList
>
> -- 
> Rick



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

Reply via email to