You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Karikalan Kumaresan <KK...@buildonline.com> on 2004/01/08 18:30:28 UTC

Uploading in Struts !!!

Hi,

I am trying to implement a multiple file uploader.. even thought I have a
solution using FilePart of O'reilly.. I want to implement it using struts...
I am looking at the following...

	MultipartRequestHandler
	CommonsMultipartRequestHandler
	FormFile
	DiskFile 

Not sure how we can make use of this in Struts framework, if you have any
sample code to achieve this, please do send it, any help would be greatly
appreciated.

Thanks in advance,
Cheers,
Kari...

-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: 05 January 2004 12:51
To: Struts Developers List
Subject: RE: Please add this Tiles tutorial to the tutorial list....


We don't maintain the Resource Pages anymore, but there's a Struts site at
SourceForge that has picked up where we left off. 

<http://struts.sf.net> 

So, you'd want to post these links to the list or tracking are there. 

-Ted.

On Mon, 05 Jan 2004 00:34:07 -0700, Richard Hightower wrote:
> Specifically...
>
>
> http://jakarta.apache.org/struts/resources/tutorials.html
>
>
> Rick Hightower
> Developer
>
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: Richard Hightower [mailto:rhightower@arc-mind.com] Sent:
> Monday, January 05, 2004 12:25 AM To: Struts Developers List
> Subject: RE: Please add this Tiles tutorial to the tutorial list....
>
>
> It has only been out since Dec. 2003 so it is new.
>
>
> Rick Hightower
> Developer
>
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: Richard Hightower [mailto:rhightower@arc-mind.com] Sent:
> Monday, January 05, 2004 12:23 AM To: struts-dev@jakarta.apache.org
> Subject: Please add this Tiles tutorial to the tutorial list....
>
>
> Please add this Tiles tutorial to the tutorial list....
> http://www.arc-mind.com/downloads.htm
>
>
> The Tiles framework makes creating reusable pages and visual
> components easier. Developers can build Web applications by
> assembling reusable tiles. You can use tiles as templates or as
> visual components.
>
> In some respects, the tile layout is like a display function. First
> you pass tile layout parameters to use. The parameters can be
> simple strings, beans, or tiles. The parameters become attributes
> to the tile and get stored in the tile's tile scope. For its part,
> the tile scope resembles page scope, and is less general than
> request scope. The tile scope lets the tile's user pass arguments
> (called attributes) to the tile.
>
> Definitions let you define default parameters for tiles.
> Definitions can be defined in JSP or XML. Definitions can extend
> other definitions similarly to how a class can extend another
> class. Moreover, definitions can override parts of the definition
> it is extending.
>
> The Tiles framework includes its own RequestProcessor to handle
> tile layouts as ActionForwards. Thus you can forward to a tile
> definition instead of a JSP if you install the Tiles plug-in.
>
> If you are using Struts but not Tiles, then you are not fully
> benefiting from Struts and likely repeat yourself unnecessarily.
> The Tiles framework makes creating reusable site layouts and visual
> components feasible.
>
>
> In this tutorial you will cover the following:
>
>
> The Tiles framework and architecture
> How to build and use a tile layout as a site template
> How to use tile definitions both in XML and JSP
> How to move objects in and out of tile scope
> How to work with attributes lists
> How to nest tiles
> How to build and use tile layouts as small visual components How to
> subclass a definition How to create a controller for a tile How to
> use a tile as an ActionForward
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org




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

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


RE: Multiple file uploads (was: Uploading in Struts !!!)

Posted by Hubert Rabago <ja...@yahoo.com>.
Karikalan, there has been several discussions about uploading files on the user
list, some I think even from the past couple of days.  The example Andrew
mentioned is struts-upload.war in the webapps directory of the Struts
distribution.  It comes with source code.

This may not apply to you, but a strategy I like to use for supporting multiple
file uploads is allowing users to upload a single zip file containing all the
files they want to upload.  As a user, I prefer this as opposed to having to
browse to different files individually.  In some cases, it even speeds up the
transfer if the data ends up getting compressed.  On my struts Action class, I
just unzip it when I get it and process each file individually the way I would an
individually uploaded file.

--- Andrew Hill <an...@gridnode.com> wrote:
> Hi Kari,
> 
> [nb: This question should be asked on the struts-user list and not the
> developer list, so Im posting my response there instead.]
> 
> Uploading files in struts is relatively straightforward. (Compared to not
> using struts! ;-> )
> 
> Theres an upload example you can look at to get some implementation details,
> but basically you make sure your html form is using multipart encoding , and
> for the file field you use a FormFile as the getter/setter type in the
> action form.
> 
> Note that you cant use an array of these like you can with other field
> types. :-(
> 
> There are a couple of ways to handle multiple file uploads. The simplest is
> if the maximum number of files is fixed (and relatively low). That is of
> course just to have several FormFile fields with different names.
> 
> If you need to allow any number of files it gets a bit more complicated.
> 
> The way I do it is to have a single FormFile setter - but when called it
> adds the formfile to a collection inside the actionform. From the users
> perspective they see a single browse button, and they choose one file at a
> time and click an 'update' button that submits the form (this is a different
> button to the one they click when they have finished filling in the form
> completely). The action it submits to returns the user to the view
> afterwards. The name of the file(s) they have uploaded so far are displayed
> in a table above the upload control. (Note that you will need the actionForm
> to be session scoped for this to work).
> 
> Sorry if this reply is a bit vague - its 2am and I need to get home and have
> something to eat, however Ive posted about this technique before on the list
> (in more detail) so a search of the archive should give you more info.
> 
> hth
> Andrew
> 
> 
> -----Original Message-----
> From: Karikalan Kumaresan [mailto:KKumaresan@buildonline.com]
> Sent: Friday, 9 January 2004 01:30
> To: 'Struts Developers List'
> Subject: Uploading in Struts !!!
> 
> 
> Hi,
> 
> I am trying to implement a multiple file uploader.. even thought I have a
> solution using FilePart of O'reilly.. I want to implement it using struts...
> I am looking at the following...
> 
> 	MultipartRequestHandler
> 	CommonsMultipartRequestHandler
> 	FormFile
> 	DiskFile
> 
> Not sure how we can make use of this in Struts framework, if you have any
> sample code to achieve this, please do send it, any help would be greatly
> appreciated.
> 
> Thanks in advance,
> Cheers,
> Kari...
> 
> -----Original Message-----
> From: Ted Husted [mailto:husted@apache.org]
> Sent: 05 January 2004 12:51
> To: Struts Developers List
> Subject: RE: Please add this Tiles tutorial to the tutorial list....
> 
> 
> We don't maintain the Resource Pages anymore, but there's a Struts site at
> SourceForge that has picked up where we left off.
> 
> <http://struts.sf.net>
> 
> So, you'd want to post these links to the list or tracking are there.
> 
> -Ted.
> 
> On Mon, 05 Jan 2004 00:34:07 -0700, Richard Hightower wrote:
> > Specifically...
> >
> >
> > http://jakarta.apache.org/struts/resources/tutorials.html
> >
> >
> > Rick Hightower
> > Developer
> >
> >
> > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> >
> >
> > Struts/J2EE consulting --
> > http://www.arc-mind.com/consulting.htm#StrutsMentoring
> >
> >
> > -----Original Message-----
> > From: Richard Hightower [mailto:rhightower@arc-mind.com] Sent:
> > Monday, January 05, 2004 12:25 AM To: Struts Developers List
> > Subject: RE: Please add this Tiles tutorial to the tutorial list....
> >
> >
> > It has only been out since Dec. 2003 so it is new.
> >
> >
> > Rick Hightower
> > Developer
> >
> >
> > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> >
> >
> > Struts/J2EE consulting --
> > http://www.arc-mind.com/consulting.htm#StrutsMentoring
> >
> >
> > -----Original Message-----
> > From: Richard Hightower [mailto:rhightower@arc-mind.com] Sent:
> > Monday, January 05, 2004 12:23 AM To: struts-dev@jakarta.apache.org
> > Subject: Please add this Tiles tutorial to the tutorial list....
> >
> >
> > Please add this Tiles tutorial to the tutorial list....
> > http://www.arc-mind.com/downloads.htm
> >
> >
> > The Tiles framework makes creating reusable pages and visual
> > components easier. Developers can build Web applications by
> > assembling reusable tiles. You can use tiles as templates or as
> > visual components.
> >
> > In some respects, the tile layout is like a display function. First
> > you pass tile layout parameters to use. The parameters can be
> > simple strings, beans, or tiles. The parameters become attributes
> > to the tile and get stored in the tile's tile scope. For its part,
> > the tile scope resembles page scope, and is less general than
> > request scope. The tile scope lets the tile's user pass arguments
> > (called attributes) to the tile.
> >
> > Definitions let you define default parameters for tiles.
> > Definitions can be defined in JSP or XML. Definitions can extend
> > other definitions similarly to how a class can extend another
> > class. Moreover, definitions can override parts of the definition
> > it is extending.
> >
> > The Tiles framework includes its own RequestProcessor to handle
> > tile layouts as ActionForwards. Thus you can forward to a tile
> > definition instead of a JSP if you install the Tiles plug-in.
> >
> > If you are using Struts but not Tiles, then you are not fully
> > benefiting from Struts and likely repeat yourself unnecessarily.
> > The Tiles framework makes creating reusable site layouts and visual
> > components feasible.
> >
> >
> > In this tutorial you will cover the following:
> >
> >
> > The Tiles framework and architecture
> > How to build and use a tile layout as a site template
> > How to use tile definitions both in XML and JSP
> > How to move objects in and out of tile scope
> > How to work with attributes lists
> > How to nest tiles
> > How to build and use tile layouts as small visual components How to
> > subclass a definition How to create a controller for a tile How to
> > use a tile as an ActionForward
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

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


RE: Uploading in Struts !!!

Posted by Andrew Hill <an...@gridnode.com>.
Hi Kari,

[nb: This question should be asked on the struts-user list and not the
developer list, so Im posting my response there instead.]

Uploading files in struts is relatively straightforward. (Compared to not
using struts! ;-> )

Theres an upload example you can look at to get some implementation details,
but basically you make sure your html form is using multipart encoding , and
for the file field you use a FormFile as the getter/setter type in the
action form.

Note that you cant use an array of these like you can with other field
types. :-(

There are a couple of ways to handle multiple file uploads. The simplest is
if the maximum number of files is fixed (and relatively low). That is of
course just to have several FormFile fields with different names.

If you need to allow any number of files it gets a bit more complicated.

The way I do it is to have a single FormFile setter - but when called it
adds the formfile to a collection inside the actionform. From the users
perspective they see a single browse button, and they choose one file at a
time and click an 'update' button that submits the form (this is a different
button to the one they click when they have finished filling in the form
completely). The action it submits to returns the user to the view
afterwards. The name of the file(s) they have uploaded so far are displayed
in a table above the upload control. (Note that you will need the actionForm
to be session scoped for this to work).

Sorry if this reply is a bit vague - its 2am and I need to get home and have
something to eat, however Ive posted about this technique before on the list
(in more detail) so a search of the archive should give you more info.

hth
Andrew


-----Original Message-----
From: Karikalan Kumaresan [mailto:KKumaresan@buildonline.com]
Sent: Friday, 9 January 2004 01:30
To: 'Struts Developers List'
Subject: Uploading in Struts !!!


Hi,

I am trying to implement a multiple file uploader.. even thought I have a
solution using FilePart of O'reilly.. I want to implement it using struts...
I am looking at the following...

	MultipartRequestHandler
	CommonsMultipartRequestHandler
	FormFile
	DiskFile

Not sure how we can make use of this in Struts framework, if you have any
sample code to achieve this, please do send it, any help would be greatly
appreciated.

Thanks in advance,
Cheers,
Kari...

-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: 05 January 2004 12:51
To: Struts Developers List
Subject: RE: Please add this Tiles tutorial to the tutorial list....


We don't maintain the Resource Pages anymore, but there's a Struts site at
SourceForge that has picked up where we left off.

<http://struts.sf.net>

So, you'd want to post these links to the list or tracking are there.

-Ted.

On Mon, 05 Jan 2004 00:34:07 -0700, Richard Hightower wrote:
> Specifically...
>
>
> http://jakarta.apache.org/struts/resources/tutorials.html
>
>
> Rick Hightower
> Developer
>
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: Richard Hightower [mailto:rhightower@arc-mind.com] Sent:
> Monday, January 05, 2004 12:25 AM To: Struts Developers List
> Subject: RE: Please add this Tiles tutorial to the tutorial list....
>
>
> It has only been out since Dec. 2003 so it is new.
>
>
> Rick Hightower
> Developer
>
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: Richard Hightower [mailto:rhightower@arc-mind.com] Sent:
> Monday, January 05, 2004 12:23 AM To: struts-dev@jakarta.apache.org
> Subject: Please add this Tiles tutorial to the tutorial list....
>
>
> Please add this Tiles tutorial to the tutorial list....
> http://www.arc-mind.com/downloads.htm
>
>
> The Tiles framework makes creating reusable pages and visual
> components easier. Developers can build Web applications by
> assembling reusable tiles. You can use tiles as templates or as
> visual components.
>
> In some respects, the tile layout is like a display function. First
> you pass tile layout parameters to use. The parameters can be
> simple strings, beans, or tiles. The parameters become attributes
> to the tile and get stored in the tile's tile scope. For its part,
> the tile scope resembles page scope, and is less general than
> request scope. The tile scope lets the tile's user pass arguments
> (called attributes) to the tile.
>
> Definitions let you define default parameters for tiles.
> Definitions can be defined in JSP or XML. Definitions can extend
> other definitions similarly to how a class can extend another
> class. Moreover, definitions can override parts of the definition
> it is extending.
>
> The Tiles framework includes its own RequestProcessor to handle
> tile layouts as ActionForwards. Thus you can forward to a tile
> definition instead of a JSP if you install the Tiles plug-in.
>
> If you are using Struts but not Tiles, then you are not fully
> benefiting from Struts and likely repeat yourself unnecessarily.
> The Tiles framework makes creating reusable site layouts and visual
> components feasible.
>
>
> In this tutorial you will cover the following:
>
>
> The Tiles framework and architecture
> How to build and use a tile layout as a site template
> How to use tile definitions both in XML and JSP
> How to move objects in and out of tile scope
> How to work with attributes lists
> How to nest tiles
> How to build and use tile layouts as small visual components How to
> subclass a definition How to create a controller for a tile How to
> use a tile as an ActionForward
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org




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

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



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