struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Prasad, Kamakshya" <kpra...@capitalservicing.co.jp>
Subject RE: Multiple File Upload using Struts (number of files dynamic)
Date Fri, 09 Jul 2004 09:18:16 GMT
Hi,

U don't need to add attribute to form bean class. 

Keep an arraylist of formfiles in form bean.

In the screen use javascript to add a new input tag to the list of file
inputs.

Then struts will take care of populating the formFiles arraylist with
these set of files after the form submission

KP

-----Original Message-----
From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com] 
Sent: Friday, July 09, 2004 6:11 PM
To: Struts Users Mailing List
Subject: RE: Multiple File Upload using Struts (number of files dynamic)

Can we add the attribute to the form bean class at runtime... 

if this is possible whenever user will click on ADD MORE button on jsp
page, I will add the attribute in form bean java class...

Is this possible using java reflection api.???

-----Original Message-----
From: kamakshya_mishra(int) 
Sent: Friday, July 09, 2004 9:19 AM
To: Struts Users Mailing List
Cc: Ketan_Bhat
Subject: RE: Multiple File Upload using Struts (number of files dynamic)

HI,

Try this one...

Put it in your form bean

private ArrayList formFiles = new ArrayList();

public void setTestFile(int iIndex, FormFile formFile)
{
    this.formFiles.add(formFiles); 
}

public FormFile getTestFile(int iIndex)
{
    while(this.formFiles.size() <= iIndex)
    {
        this.formFiles.add(new FormFile()); 
    }
    return (FormFile) formFiles.get(iIndex); 
}

public ArrayList getTestFiles()
{
    return this.formFiles; 
}

Keep the property of input box as "testFile"

KP

-----Original Message-----
From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com] 
Sent: Thursday, July 08, 2004 5:40 PM
To: Struts Users Mailing List
Cc: Ketan_Bhat
Subject: RE: Multiple File Upload using Struts (number of files dynamic)


Thanks KP

Could you please elaborate on this..

What I understood is that have an ArrayList of FormFile in the form bean
class... now query is how this arraylist will get populated ?

If I need to create an ArrayList in JSP then how to get FormFile
element?

I am not aware of dynamic list control.

Could you please provide code snippet of reference?

Regards,
Viral

-----Original Message-----
From: kamakshya_mishra(int) 
Sent: Thursday, July 08, 2004 12:01 PM
To: Struts Users Mailing List
Cc: Ketan_Bhat
Subject: RE: Multiple File Upload using Struts (number of files dynamic)

Hi,

In the form bean keep an array list of FormFile and use it similarly as
dynamic list control.

KP

-----Original Message-----
From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com] 
Sent: Thursday, July 08, 2004 3:01 PM
To: Struts Users Mailing List
Cc: Ketan_Bhat
Subject: Multiple File Upload using Struts (number of files dynamic)

Hi,
 
We are trying to implement uploading file via struts framework using
form bean. According to our requirement we have two scenarios' in which
we require uploading of our file.
1)       Uploading single file (single html:file control and a single
upload button in jsp page)
2)      Uploading multiple files (Multiple html:file controls on the
screen on the same form). 
The problem is that these number of html:file controls on the screen is
not fixed, it is dynamic. The user can click on an "Add More" button to
increase dynamically the number of files he/she wants to upload.
 
We have implemented the first scenario by using html:file tag on the JSP
and keeping a form bean with html control as one of its member
variables. In the action class we extract the value from the bean and
then upload the file using I/O streams. 
 
Now, for the second scenario we need to upload an indeterminate
(determined at run time) number of files but at the same time the number
of members in the bean class cannot be changed dynamically. 
 
So we either need a way to add members to a form bean dynamically or
some other mechanism which will handle this multiple upload requirement.
 
With Regards,
Viral

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




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


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



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


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


Mime
View raw message