• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to make a file chooser in struts?

 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. If I use applets can it be "integrated" in struts?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay! Thanks so much for the information!

God bless.

Darren
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic