Yep... Solved. I was being dumb. One can only set an object where a setter
exists. So, even if I prepopulate a Collection with Apple objects I can't
add the apple object straight to the collection by ending my collection
referencing property name with an index(property="apples[0]"). Instead, I
should prepopulate the collection with objects that contain a setApple(Apple
apple) method and call the single property (property="apples[0].apple").

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws


-----Original Message-----
From: Brandon Goodin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 1:27 PM
To: Struts Users Mailing List
Subject: RE: FormFile question


I think my solution is much simpler. Instead of trying to place the FormFile
directly into the colleciton I need to create a bean that will wrap the
FormFile and hold the value as a property (setter/getter). I'll try that and
post my findings. I have never used a property name that ended with an index
number. Perhaps this is not a proper use.

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws


-----Original Message-----
From: alexj [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 1:09 PM
To: Struts Users Mailing List
Subject: Re: FormFile question


you never add element into your collection and you try to access an
indefined index .

----- Original Message -----
From: "Brandon Goodin" <[EMAIL PROTECTED]>
To: "Struts User List" <[EMAIL PROTECTED]>
Sent: Wednesday, January 29, 2003 9:02 PM
Subject: FormFile question


> I have a page that uploads multiple files. I want to place these files
into
> a Collection. I keep getting an IndexOutOfBoundException. I have used the
> lazyList extensively to fill other collections without issue. This is the
> first time I have tried to use if for a file upload.
>
> Just for observation you may notice, in the code example, I do not have a
> formFiles[0] index. The lazyList normally cures this because the Array is
> prepopulated with Objects which are specified as the second parameter of
> lazyList method.
>
> I believe the problem to be that I am not populating the lazyList with the
> right Objects. The problem that I am facing is finding out what kind of
> Object uploaded files are translated to. I know about the FormFile.. but
it
> is an interface and (obviously) can't instantiate that. So what object do
I
> need to prepopulate my lazyList with to allow the uploaded files objects
to
> be put into a collections?
>
> For example:
>
> JAVA Code:
>
> public class MyClass{
>
> Collection formFiles;
>
> public MyClass() {
> this.formFiles = ListUtils.lazyList(new ArrayList(),new
> java.lang.Object());
> }
>
> public setFormFiles(Collection formFiles) {
> this.formFiles = ListUtils.lazyList(new ArrayList(formFiles),new
> java.lang.Object());
> }
>
> }
>
> ...
> JSP Page:
> <html:file name="formFiles[1]"/>
>
> Upon submittal I get an exception like...
> java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
>
> Thanks,
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> [EMAIL PROTECTED]
> http://www.phase.ws
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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



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



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

Reply via email to