Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFileChooser from a backing bean / web page

 
Hernán Quevedo
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hernán Quevedo
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21313
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic