Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Programmatically Request New Page/URL Load in Existing Browser Window/Tab?(What is the opposite of ExternalBrowser?)
Programmatically Request New Page/URL Load in Existing Browser Window/Tab? [message #1746865] Sun, 06 November 2016 22:08 Go to next message
Eric Domeshek is currently offline Eric DomeshekFriend
Messages: 9
Registered: October 2016
Junior Member
Pardon me if there is an obvious answer to this question, but is there any way in RAP to get something like the effect of programmatically launching an ExternalBrowser on a specified URL, but to have the new page be displayed NOT in a (new) external browser, but rather in the CURRENT browser window/tab?

I think I want the effect of a Link (or an 'a' tag embedded in a Label), but to have it be under program control--generally at the end of handling some event like a button click or menu selection. For instance, a menu action might created a new piece of data, and I want to then load the URL/page for that data.

I realize this is a bit counter to the default RAP assumption of a long-lived single-page web application. Is it doable in RAP?

Thanks for any advice,

--Eric
Re: Programmatically Request New Page/URL Load in Existing Browser Window/Tab? [message #1746866 is a reply to message #1746865] Sun, 06 November 2016 23:03 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 192
Registered: February 2011
Senior Member
Have a look at org.eclipse.rap.rwt.client.service.JavaScriptExecutor.execute(String)

Something like (I haven't run this code...) RWT.getClient().getService(JavaScriptExecutor.class).execute("window.location.href=\"" + url + "\";");
Re: Programmatically Request New Page/URL Load in Existing Browser Window/Tab? [message #1746995 is a reply to message #1746865] Tue, 08 November 2016 12:28 Go to previous messageGo to next message
Sebastian Habenicht is currently offline Sebastian HabenichtFriend
Messages: 27
Registered: January 2013
Junior Member
Depending on the the created piece of data, you may also use a Dialog with a Browser widget and show the data in that browser - either by creating the respective html code and set it using Browser#setText or by creating a (temporary) file on the web server and show it using Browser#setUrl.

I think this is quite nice since the application remains visible and the presented content looks like being part of it. Additionally, the user can benefit from the dialog functionality (e.g. resize the dialog or drag it around). And finally, you have access to the browser widget, e.g. to add a ProgressListener or to react on events in the page (see BrowserFunctions). More info about it: [1]

However, this is probably no solution if you want to access external content, since the Browser widget is represented by an iframe and displaying external content in frames may be denied (X-Frame-Options, see [2]) or you may run into issues due to cross-frame-scripting restrictions.

If you create html code during runtime, make sure to test the functionality in all browsers you support.

[1] https://www.eclipse.org/rap/developers-guide/devguide.php?topic=web-embedding.html&version=3.0
[2] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

[Updated on: Tue, 08 November 2016 12:30]

Report message to a moderator

Re: Programmatically Request New Page/URL Load in Existing Browser Window/Tab? [message #1747126 is a reply to message #1746866] Wed, 09 November 2016 19:01 Go to previous messageGo to next message
Eric Domeshek is currently offline Eric DomeshekFriend
Messages: 9
Registered: October 2016
Junior Member
Thank you very much Chris. This appears to work and to do exactly what I want.
Re: Programmatically Request New Page/URL Load in Existing Browser Window/Tab? [message #1747127 is a reply to message #1746995] Wed, 09 November 2016 19:03 Go to previous message
Eric Domeshek is currently offline Eric DomeshekFriend
Messages: 9
Registered: October 2016
Junior Member
Thank you Sebastian for the suggestion. I'll keep it in mind for other possible uses that may arise as I keep developing. However, I think Chris's approach does exactly what I was hoping for.
Previous Topic:[ANN] RAP 3.2 M3 published
Next Topic:Charts and JS
Goto Forum:
  


Current Time: Sun Feb 18 02:03:37 GMT 2018

Powered by FUDForum. Page generated in 0.01517 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software