Skip to main content

Semantics of Desktop.browse

5 replies [Last post]
chas
Offline
Joined: 2004-06-23

While testing an unexpected behavior (https://jdic.dev.java.net/issues/show_bug.cgi?id=130) in a development branch, a question of the behavior of Desktop.browse(url) arose. Does browse a URL mean: behavior A, use the desktop protocol associations to find the application to open the URL; or behavior B, use the default web browser to open the URL?

This code branch has added protocol associations. You can retrieve an association for "http" and execute the open action with the URL as the argument.

Behavior A could be implemented as getProtocolAssociation(url.getProtocol()).getAction("open").execute(url).
The original intent of browse(url) was behavior B. This could be implemented as getProtocolAssociation("http").getAction("open").execute(url).

For example, I have my desktop associations set up so that Mozilla is my web browser and Outlook is my mail client. Calling Desktop.browse("mailto:chas@jdic.net") will: with behavior A, launch Outlook; with behavior B, launch the Mozilla mail client.

Which behavior are developers and end users expecting?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Thorsten Laux

I believe your use case is less of an issue because you'll have to fix
the mailto association in the browser anyway
(Preferences/Mail&Newsgroups/Use Mozilla Mail as default mail
application). Otherwise mailto URLs will not work correctly when clicked
on a web page.

Anyway this is an interesting question. You could use Desktop.open to
get behavior A but is takes a File not a URL.

On windows we could support taking a URL since ShellExecute
(http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference...)
supports opening URLs. I believe GNOME supports opening URLs as well but
I'm not sure about other verbs. I'm not sure about MacOS X. Paul &
George could you check this out?

I do think we want to keep behavior B for browse. For some cases you
just want to have a browser handling the content (e.g. to have a pdf
displayed in a browser instance and be able to navigate to other URLs in
the same window).

Thorsten

jdic@javadesktop.org wrote:
> While testing an unexpected behavior (https://jdic.dev.java.net/issues/show_bug.cgi?id=130) in a development branch, a question of the behavior of Desktop.browse(url) arose. Does browse a URL mean: behavior A, use the desktop protocol associations to find the application to open the URL; or behavior B, use the default web browser to open the URL?
>
> This code branch has added protocol associations. You can retrieve an association for "http" and execute the open action with the URL as the argument.
>
> Behavior A could be implemented as getProtocolAssociation(url.getProtocol()).getAction("open").execute(url).
> The original intent of browse(url) was behavior B. This could be implemented as getProtocolAssociation("http").getAction("open").execute(url).
>
> For example, I have my desktop associations set up so that Mozilla is my web browser and Outlook is my mail client. Calling Desktop.browse("mailto:chas@jdic.net") will: with behavior A, launch Outlook; with behavior B, launch the Mozilla mail client.
>
> Which behavior are developers and end users expecting?
> ---
> [Message sent by forum member 'chas' (Charles Honton)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=38892&#38892
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdic-unsubscribe@jdic.dev.java.net
> For additional commands, e-mail: jdic-help@jdic.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jdic-unsubscribe@jdic.dev.java.net
For additional commands, e-mail: jdic-help@jdic.dev.java.net

georgez
Offline
Joined: 2003-08-19

Hi Chas,

> For example, I have my desktop associations set up so that Mozilla is my web browser and Outlook is my mail client. Calling Desktop.browse("mailto:chas@jdic.net") will: with behavior A, launch Outlook; with behavior B, launch the Mozilla mail client.

In this case, behavior A seems reasonable. This is one case that the default browser is not registered as the content handler of protocols. The "mailto" protocol specifying the default mail client is a little bit special, as it's often different from the default browser. For this case, we have the Desktop.mail() and Desktop.mail(Message) APIs to launch the default mail client.

But for the other protocols, I think they are corner cases. We can afford using the default browser, which is clear from its name.

So, I'd suggest we keep behavior B (launch Mozilla mail client) for Desktop.browse("mailto:chas@jdic.net"). And if the user wants to launch the mail client, he should can use Desktop.mail(Message msg).

-George.
-------------------
Sorry, I intended to suggest behavior B (launch Mozilla mail client)
Message was edited by: georgez

primet21
Offline
Joined: 2006-02-17

i believe Behavior A would be more useful especially in the example you gave...it allows a java program to use the system defaults to open a url rather than letting the browser choose what to use...in my opinion, Behavior A would be a step up from Behavior B...

Anonymous

Currently, there is a refactoring work on going for the JDIC project. Chas is a major contributor for this.

We'd like to hear the community voice for this API and thus reflect the expection in the ultimate implementation.

Thanks

Anonymous

The original design of this API is to mimic the behavior of viewing the url with the system default browser.
Imaging typing mailto:jdic@dev.java.net in the Mozilla browser window and you'll get Mozilla mail client popup.
With this in mind, I would prefer to decide the behavior by browser instead of the desktop.

-Paul