You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Lindholm <gl...@yahoo.com> on 2009/03/18 20:50:26 UTC

File upload, validation and Preparable

Got a couple questions about file uploading.

I've discovered that in the standard interceptor stack "fileUpload" is after "prepare" interceptor. This means that the upload File, ContentType, and FileName setters have not been called before prepare() method runs.  Is there a good reason for this?  It seems like fileUpload should be before prepare so that these "parameters" have been set and are available to the prepare() method. What do you think?

One of the problems I'm having is that if the page fails validation (on some other field) then the user selection in the <s:file> tag is lost.  The result="input" takes me back to the page but the File selection is blank.  Is there a way to preserve the users file selection when validation fails? 

If I do a show source on the page after validation fails the input file tag has it's value= attribute set the temp file name from the server. This doesn't seem right?  This is leaking server configuration (albeit not very important)  information back to the client.





      

RE: File upload, validation and Preparable

Posted by "Kawczynski, David" <da...@merck.com>.
I'm pretty sure you can't prepopulate input tags whose type=file.
This is html4 and has nothing to do with struts.


-----Original Message-----
From: Greg Lindholm [mailto:glindholm@yahoo.com] 
Sent: Wednesday, March 18, 2009 4:17 PM
To: user@struts.apache.org
Subject: Re: File upload, validation and Preparable


BTW That's Struts 2.1.6 and Tomcat 5.5.


Greg Lindholm wrote:
> 
> Got a couple questions about file uploading.
> 
> I've discovered that in the standard interceptor stack "fileUpload" is
> after "prepare" interceptor. This means that the upload File, ContentType,
> and FileName setters have not been called before prepare() method runs. 
> Is there a good reason for this?  It seems like fileUpload should be
> before prepare so that these "parameters" have been set and are available
> to the prepare() method. What do you think?
> 
> One of the problems I'm having is that if the page fails validation (on
> some other field) then the user selection in the <s:file> tag is lost. 
> The result="input" takes me back to the page but the File selection is
> blank.  Is there a way to preserve the users file selection when
> validation fails? 
> 
> If I do a show source on the page after validation fails the input file
> tag has it's value= attribute set the temp file name from the server. This
> doesn't seem right?  This is leaking server configuration (albeit not very
> important)  information back to the client.
> 
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/File-upload%2C-validation-and-Preparable-tp22587156p22587594.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.


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


Re: File upload, validation and Preparable

Posted by Greg Lindholm <gl...@yahoo.com>.
BTW That's Struts 2.1.6 and Tomcat 5.5.


Greg Lindholm wrote:
> 
> Got a couple questions about file uploading.
> 
> I've discovered that in the standard interceptor stack "fileUpload" is
> after "prepare" interceptor. This means that the upload File, ContentType,
> and FileName setters have not been called before prepare() method runs. 
> Is there a good reason for this?  It seems like fileUpload should be
> before prepare so that these "parameters" have been set and are available
> to the prepare() method. What do you think?
> 
> One of the problems I'm having is that if the page fails validation (on
> some other field) then the user selection in the <s:file> tag is lost. 
> The result="input" takes me back to the page but the File selection is
> blank.  Is there a way to preserve the users file selection when
> validation fails? 
> 
> If I do a show source on the page after validation fails the input file
> tag has it's value= attribute set the temp file name from the server. This
> doesn't seem right?  This is leaking server configuration (albeit not very
> important)  information back to the client.
> 
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/File-upload%2C-validation-and-Preparable-tp22587156p22587594.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: File upload, validation and Preparable

Posted by Dave Newton <ne...@yahoo.com>.
Greg Lindholm wrote:
> Same is true for both  "paramsPrepareParams" stack and "defaultStack", the
> fileUpload is after the prepare interceptor (sorry, I didn't make it clear I
> was talking about paramsPrepareParams).

Meh, my thinking was broken when I posted that anyway; I wasn't thinking 
about the files.

> So you also thought (or believe) the fileUpload interceptor should be before
> the prepare interceptor in the paramsPrepareParams stack?

I haven't had a situation where I've needed file information in a 
preparable method, so it doesn't really bother me that much :)

 > That's way I'm asking is there any reason it isn't?

I can't think of any reason off the top of my head, but I've already 
been broken on this thread once, so who knows.

Dave


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


Re: File upload, validation and Preparable

Posted by Greg Lindholm <gl...@yahoo.com>.


newton.dave wrote:
> 
> Greg Lindholm wrote:
>> I've discovered that in the standard interceptor stack "fileUpload"
>> is after "prepare" interceptor. This means that the upload File,
>> ContentType, and FileName setters have not been called before
>> prepare() method runs.  Is there a good reason for this?  It seems
>> like fileUpload should be before prepare so that these "parameters"
>> have been set and are available to the prepare() method. What do you
>> think?
> 
> That's why the "paramsPrepareParams" stack exists.
> 
> 
Dave,

Same is true for both  "paramsPrepareParams" stack and "defaultStack", the
fileUpload is after the prepare interceptor (sorry, I didn't make it clear I
was talking about paramsPrepareParams).

So you also thought (or believe) the fileUpload interceptor should be before
the prepare interceptor in the paramsPrepareParams stack?   That's way I'm
asking is there any reason it isn't?

Greg
-- 
View this message in context: http://www.nabble.com/File-upload%2C-validation-and-Preparable-tp22587156p22619912.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: File upload, validation and Preparable

Posted by Dave Newton <ne...@yahoo.com>.
Greg Lindholm wrote:
> I've discovered that in the standard interceptor stack "fileUpload"
> is after "prepare" interceptor. This means that the upload File,
> ContentType, and FileName setters have not been called before
> prepare() method runs.  Is there a good reason for this?  It seems
> like fileUpload should be before prepare so that these "parameters"
> have been set and are available to the prepare() method. What do you
> think?

That's why the "paramsPrepareParams" stack exists.

> One of the problems I'm having is that if the page fails validation
> (on some other field) then the user selection in the <s:file> tag is
> lost.  The result="input" takes me back to the page but the File
> selection is blank.  Is there a way to preserve the users file
> selection when validation fails?

No; you can't pre-set file input values--as David said this is an HTML 
thing, not Struts.

> If I do a show source on the page after validation fails the input
> file tag has it's value= attribute set the temp file name from the
> server. This doesn't seem right?  This is leaking server
> configuration (albeit not very important)  information back to the
> client.

That's probably true.

Dave


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