wood burning stoves 2.0*
The moose likes JSF and the fly likes Retain File Selected in a File Upload Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Retain File Selected in a File Upload Component" Watch "Retain File Selected in a File Upload Component" New topic
Author

Retain File Selected in a File Upload Component

Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
I am using a File Upload Component to allow users to browse to the file, and choose one. I do not want to upload the file but just get the File Path.
I am able to do this without any problem.
However, there are value change events that cause form submit and if the user selected/chose the file before these events then the value is lost.
I want to retain the chosen file path in the Upload component even after form submits caused by value change events.Is there any way to handle this?
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Found my answer while going through posts!

Problem with t:inputFileUpload

Seems Like I will have to invest the time in a creating a custom File Chooser Component (Similar to one in Swing) !
[ November 14, 2008: Message edited by: Kavita Tipnis ]
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
After pondering on how to implement a file chooser component, I came up with a work around and I feel like sharing it with all the ranchers!
Problem - Choosing a file path,saving only the path and no file upload, any other form submit (such as value change) would cause the upload component(Tomahawk,Richfaces woodstock...)to lose it's value causing user annoyance!
Solution/Work Around - I created the file upload component in another jsf page and on submitting that page I take the value of the Uploaded File and put it on the required page.

Here is the code



This will work for any file upload component , I have used Woodstock.
This was useful to me, it may not be a good way to do it or developers might be doing it in some efficient way!
But It works!
Note : I tried putting the javascript(to open the pop up) in an external file, it works but never sets focus to the new window(problem occurs in IE!!). Any insight on this would be great !

(onkclick - because I could not type 'C'!!)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retain File Selected in a File Upload Component
 
Similar Threads
How to retain a selected file path in a input type="file" in html
Not able to persist the absolute path of selected file in file upload control.
Facing problem with tomahawk <t:inputFileUpload> component
reset value of formFile
Uploading file