try nested tags for file object in jsp and array of formfile for getter and
setters

<nested:file

-----Original Message-----
From: Jeremiah Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 13, 2006 6:23 AM
To: Struts Users Mailing List
Subject: Re: FormFile arrays


David Grundberg wrote:
> You are right about the jakarta commons fileupload and struts, you
> can't use commons fileupload in an action, because struts have already
> taken care of the multi-part parsing. You do have the option to make a
> servlet and commons fileupload, where you will have total control of
> the form data. I'm not certain about your way of making the files go
> into an array. Is that the way to do it with for example html:text?
> One would expect it to work in a similar fashion.
>
> http://www.jguru.com/faq/view.jsp?EID=915898
> This link suggests that you use the same name all over again for each
> entry, like "notworkingfile", "notworkingfile", and so on...
>
I've done this with html:text and it does work. The catch is that
html:file requires the property attribute to be specified. I could make
a class  with accessors for each FromFile. That seems convoluted.. I'm
hoping for a simpler solution then that.  I'll post code if I can make
this work.
>
> Jeremiah Johnson skrev:
>> I would like to upload multiple files on a single web page by having
>> multiple <html:file> elements. The exact number of these are
>> different depending on the user who is using the application. So I
>> want to store this in an array (FormFile[]) in order to have N number
>> of files uploaded. When I try to use <html:file/> tags in an iterate
>> loop (with indexed="true") I get an error about requiring property
>> attribute. There's isn't a good way of doing that so I just rendered
>> the the HTML with scriplets. It looks something like:
>>
>>
>> <input type="file" name="workingfile"/>
>> <input type="file" name="notworkingfile[0]"/>
>> <input type="file" name="notworkingfile[1]"/>
>> <input type="file" name="notworkingfile[2]"/>
>>
>> The form has getters and setters for workingfile (of type FormFile)
>> and notworkingfile ( of type FormFile[] that is 3 elements).
>> workingfile is assigned an instantied object however each element of
>> notworkingfile[] is null after submit.
>>
>> I then attempted to use commons-fileupload-1.1.1 in a struts action
>> (struts 1.2.9) to read the uploaded data but it does not recognize
>> that any files are being uploaded (including workingfile). I tried
>> this code:
>>
>>            List items = new ServletFileUpload(
>>                    new DiskFileItemFactory()).parseRequest(request);
>>
>> items results in an empty collection (but not null). I've read that
>> you can not use commons-fileupload in a struts action which may be
>> why that doesn't work. Anyone know how to have variable number of
>> file upload boxes? I know I could have properties for each file
>> (file1,file2,file3 and so on) instead of array but I'd rather not
>> implement it that way. Thanks!
>>
>> Jeremiah
>>
>> ---------------------------------------------------------------------
>> 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