views:

101

answers:

1

Hello everybody,

I have a JSF application and when user click on button I want to open a web page. Desktop.getDesktop().browse(uri); probably opens a web page on server side, how to do it on client side?

when i try Desktop.getDesktop().browse(uri); it works, but maybe its because I open the JSF application on localhost so I dont know if the opened uri is on server side or client side.

In the specification for getDesktop() its written:

getDesktop() 
Returns the Desktop instance of the current browser context.

Thanks!

+1  A: 

You can do this by a simple link (and perhaps style it as a button):

<h:outputLink href="otherpage.jsf" target="_blank" />

If you insist on a button, there is a way to do this with javascript, but I'd recommend against it.

When developing web applications, forget about java.awt.* and javax.swing.* - they are not to be used in web application development (unless you create applets)

Bozho
and how to see if Desktop.getDesktop().browse(uri); will open web page on client side or server side cause Desktop.getDesktop().browse(uri); is much more useful for me? any idea Bozho?
Milan
Dektop.getDesktop() won't work on client side at all. When developing webapps forget about that (and related) classes.
Bozho
hm...then I dont understand really why in the specification getDesktop() is defined like: Returns the Desktop instance of the >>>current<<< browser context. Current like client current browser or what?
Milan
if you use it in Applet, then this makes sense ;) But you aren't using an applet.
Bozho
Ok you are right:) So from JSF java bean is it possible to open web page on client side? :)
Milan
no, apart from the way I showed - using HTML/javascript techniques. (the `<h:outputLink>` is translated to `<a href=..`)
Bozho