using path hint in javax.jnlp's openFileDialog

D

David Lamb

Some months ago people here advised me to use Java Web Start (jnlp) to
develop something, and I'm finally getting time to begin investigating
how to use the javax.jnlp package. I've just implemented the action for
opening a file using the openFileDialog of the file opening service,
and selecting a file and reading its contents works fine. I've not been
able to find any explanation of how to use the path hint parameter,
though; the javadocs and tutorial just say it's a hint and nothing about
what sort of hint to give, other than supplying "null" for default
behaviour.

Can anyone tell me how to use this parameter? Can it be used to, for
example, start the next dialog in the same directory as the previous one?
 
A

Andrew Thompson

...I've just implemented the action for
opening  a file using the openFileDialog of the file opening service,
...I've not been
able to find any explanation of how to use the path hint parameter,

AFAIU, it is the path of a directory.
though; the javadocs and tutorial just say it's a hint and nothing about
what sort of hint to give, other than supplying "null" for default
behaviour.

Can anyone tell me how to use this parameter?

Supply the absolute path to a directory.
.. Can it be used to, for
example, start the next dialog in the same directory as the previous one?

Nope, not as far as I can see. Since neither the
FileOpenService or FileContents will provide the path
to the resource the user chose (only its name, in the
case of FileContents) it is impossible to get the path
for the current FOS.

About the only place I can see the file hint being
useful is in:
a) Secure code where we can supply things like ${user.home}
explicitly, or
b) When using the FS or the ExtendedService with a File
that we already know the path of. E.G. when the app.
has a File association defined & the user 'double clicks'
an associated file type, the entire path of that File is
supplied as an argument to the main(String[]).

Actually, my point 'a' is a bit disingenuous, since it
would require all-permissions to get the values of the
secure properties, we might as well just use a standard
JFileChooser and be done with it.
 
D

David Lamb

About the only place I can see the file hint being
useful is in:
a) Secure code where we can supply things like ${user.home}
explicitly, or

Actually I'm contemplating writing two versions, one assuming
all-permssions and one not. I expect I'll have to research how to
detect programmatically whether this has happened -- still digging into
the various APIs!
b) When using the FS or the ExtendedService with a File
that we already know the path of. E.G. when the app.
has a File association defined & the user 'double clicks'
an associated file type, the entire path of that File is
supplied as an argument to the main(String[]).

Not possible in this particular application, since the file type is
already owned by a separate application, but it would help for future
projects. I can certainly "guess" at the path in this very special
case, since they're almost always in a particular subdirectory of
user.home and the file dialog seems to start there anyway.
 
D

David Lamb

markspace said:
The docs say:

I said in the OP that I'd done due dilligence by reading the docs and
tutorial. Perhaps I should have guessed that "path hint" meant an
actual absolute path string as Andrew clarified, but I didn't.
 
D

David Lamb

David said:
I can certainly "guess" at the path in this very special
case, since they're almost always in a particular subdirectory of
user.home and the file dialog seems to start there anyway.

Oops, you said absolute path earlier, so relative path from user.home
wouldn't help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top