File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JFileChooser from a backing bean / web page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser from a backing bean / web page" Watch "JFileChooser from a backing bean / web page" New topic
Author

JFileChooser from a backing bean / web page

Hernán Quevedo
Ranch Hand

Joined: Mar 18, 2009
Posts: 31
Hi.

I'm having a problem with a JFileChooser 'cause I'm trying to pop it up from an action inside a . The backing bean creates a file chooser but it shows up behind the browser, behind everything, actually.
I'm using a file chooser instead of because I need to know the complete path of the file, and that tag doesn't do the work.

Is there any way to focus the file chooser above any other element on the screen?

Thnx.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

You can't do this. What's happening now, the reason it is kind of working, is because your local machine is the server, so when you execute the server side code, you see it happen. If you were to access your application from a non-server machine, you'd never see the file chooser.

The only to do what you want is to use an Applet to embed the ability for the client to launch the file chooser. Generally, there's no real need to have the clients full file path because all you should care about is the file itself. If you need something more than that, consider why you chose to use a web application in the first place.


GenRocket - Experts at Building Test Data
Hernán Quevedo
Ranch Hand

Joined: Mar 18, 2009
Posts: 31
Thanks. You're right, I can't; plus, I can't embed it in an applet. I'm toasted and depending on js tricks to find out that path cause focusing only on the file as a byte array gives me different results depending on the browser.


thanks again
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

[quote=Hernán Quevedo]... focusing only on the file as a byte array gives me different results depending on the browser.[/quote]
If you're doing a standard file upload (via <input type="file">) then the only difference you should see between browsers is that Internet Explorer (some versions, anyway) gives you the complete file path and other browsers just give you the name of the file. The bytes you get as file data should be identical in both cases.

And since the directory the file was uploaded from is (or definitely should be) irrelevant to your application, you should just ignore that if you get it.
 
wood burning stoves
 
subject: JFileChooser from a backing bean / web page