aspose file tools*
The moose likes Struts and the fly likes Is it possible to make a file chooser in struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Is it possible to make a file chooser in struts?" Watch "Is it possible to make a file chooser in struts?" New topic
Author

Is it possible to make a file chooser in struts?

Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Good day everyone!

Is it possible to make a file chooser in struts? The dialog box that lets you select a folder and then all the contents will be retrieved?


Thanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
When you use the <html:file> tag, a text box with a browse button will be displayed on the page. When the user presses the browse button, a dialog box opens up that allows the user to navigate through the local file system to find a file to upload.

If you need something more sophisticated than this, your best bet would be to write an applet that does what you want.


Merrill
Consultant, Sima Solutions
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your reply. If I use applets can it be "integrated" in struts?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It depends on what you mean by "integrate", but in general the answer is yes. You can certainly place an <applet> tag in a Struts JSP. You can also make that applet communicate with a servlet or Struts action if you want. Most of the reason for writing an applet, though is to do something that can best be done on the local system, such as browsing through files.
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Okay! Thanks so much for the information!

God bless.

Darren
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
A while back I had an odd situation where I wanted the user to be able to select a directory. The standard file chooser implemented by browsers just lets you pick a file (some may let you pick multiple files) but they do not support selecting a directory. I suspect that in order for an applet to be able to browse the local file system you would have to go through the hassle of digitally signing the applet and users may have to grant permission to the applet (though it is been 7 years since I have done applet development).

I would take a look at some of the file and video sharing sites for ideas. It seems like most of the ones that I have used have a cheesy web page where you have to select individual files to upload or they offer a standalone application that lets you upload a bunch of files at once.

- Brent
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Yes, that's my problem now. As of the moment, the one that I have done is uploading file individually. My client wants to select directory and then get all its contents. I did some research and found out that there is a fileChooser but its in Swing and AWT. I am using Struts for my application. With that I don't think it is possible. So I posted my problem in this forum and got an advice to do it on applets. But as of the moment I don't know where to start because I haven't used applets before.

Thanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Darren Alexandria:
I did some research and found out that there is a fileChooser but its in Swing and AWT.

This sounds like a good start for an applet, since applets use Swing and AWT to display graphical elements. I'd look for tutorials and articles on how to turn existing Swing applications into applets.

Also, you may want to Google "file select applet" and you'll see some examples, both commercial an non-commercial.

Here is a link to a simple one.
[ September 12, 2007: Message edited by: Merrill Higginson ]
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your help. I have been stranded in this one since it was mentioned to me. I kept on thinking what should I do. Then, after days of just staring at my computer, I realized that my work piled up already. I am thankful for your suggestions and advices.

Darren
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to make a file chooser in struts?