struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: FormFile not re-populated
Date Tue, 02 Dec 2003 02:55:38 GMT
Heres (a very simplified description of) what I do (its conceptually the
same as what James suggested):

I use a session based form for upload pages especially since I usually need
to allow the user to upload multiple files for one 'field', and because some
of these files can be quite big and the user wont appreciate having to
upload them again (and again and again (Ive noticed users always seem to
have a knack for entering invalid data!))

I have the setter in the ActionForm add the FormFile to a collection.

On return to the page (due to either a validation error or the need to
upload additional files to that 'field') I will display above the upload
control a list of files uploaded to that 'field' along with checkboxes to
allow the user to tick any they change their mind about and want to trash.

The checkboxes submit to a field whose setter takes care of removing the
unwanted FormFiles.

In addition to the forms normal submission button(s) the file field will
usually have its own 'update/remove' button that triggers a form submission
followed by a return to the view without validation.

(In my current project I actually have a class an instance of which I nest
in the actionform to take care of all this - so all my file fields are
actually nested fieldnames ie: "bob.file", "bob.filesToDelete". Would you
believe I have one form where I have something like 60+ file 'fields'! (I
wasnt given a choice about it). Oh the humanity. (I handle that using popup
windows whose actions play with the main windows session based form).)

-----Original Message-----
From: David Friedman [mailto:humble@ix.netcom.com]
Sent: Tuesday, 2 December 2003 08:40
To: Struts Users Mailing List
Subject: RE: FormFile not re-populated


Since you mentioned FormFiles and failed validations, I'd like to share
something:  It's a pain that you lose the uploaded file if the form
validation fails.  I decided to make my validation screen do a special
message to please upload the files again because form Validation failed IF
any files were uploaded.  My problem was: how do you detect if files were
uploaded?  I chose to examine my ActionForm's FormFile fields and count the
total bytes.  IF it's zero, nothing was uploaded so I won't show the
reminder to re-attach the files.

Does anyone have a better method for dealing with losing files on Validation
failure?

Thanks for any constructive feedback,
David

-----Original Message-----
From: James Mitchell [mailto:jmitchell@apache.org]
Sent: Monday, December 01, 2003 1:30 PM
To: Struts Users Mailing List
Subject: Re: FormFile not re-populated


On Mon, 1 Dec 2003, Sharmila Pandith wrote:

> Hi,
>
> I am using FormFile and after it is validated it must be displayed on the
> next JSP. However, the field is blank. When I look at the source in IE6, I
> see the file name without the directory. But even that is not displayed.
>
> Any thoughts?


Yes, basically, you cannot expect to pre-fill an input field of type
"file" (html file upload box with browse button).  It is not supported in
all browsers and those that do, prompt the user to so they can cancel the
field value or the form all-together.

You would be better off doing something like this:
1. Show page (with file upload button), and ask the user if they want
   to upload additional files (radio button or something)
2. If yes, then after that page is processed, show it again, only this
   time with file listed off to the side (similar to how a summary view
   of a shopping cart might do)
3. If no, then move along with your wizard.

Does that help?



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

--
James Mitchell
Software Developer / Struts Evangelist
http://www.struts-atlanta.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-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



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


Mime
View raw message