Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Scout RAP external html
Scout RAP external html [message #1066292] Mon, 01 July 2013 22:30 Go to next message
Li Hao is currently offline Li Hao
Messages: 28
Registered: August 2011
Junior Member
How do I add a external html link in the scout RAP app so that when user click on the link, it will open up another browser tab or windows to the external link?

I don't need to cap the external html page inside the RAP app, I just want to show up the external page without processing.
Re: Scout RAP external html [message #1066299 is a reply to message #1066292] Tue, 02 July 2013 01:12 Go to previous messageGo to next message
Stephan Leicht Vogt is currently offline Stephan Leicht Vogt
Messages: 99
Registered: February 2010
Location: Baden Switzerland
Member

Hi

You can do this by calling the IShellService:

SERVICES.getService(IShellService.class).shellOpen("http://www.eclipse.org/");


This method opens Documents and URLs in the corresponding application or in your case, Scout RAP, it would download Files and open URLs in a new Tab/Window.

Greetings
Stephan
Re: Scout RAP external html [message #1066349 is a reply to message #1066299] Tue, 02 July 2013 05:15 Go to previous messageGo to next message
Li Hao is currently offline Li Hao
Messages: 28
Registered: August 2011
Junior Member
Thanks. It works.

I notice it always open a new windows on IE/Firefox, is there any way to make it open in new tab?
Re: Scout RAP external html [message #1066354 is a reply to message #1066349] Tue, 02 July 2013 05:44 Go to previous messageGo to next message
Stephan Leicht Vogt is currently offline Stephan Leicht Vogt
Messages: 99
Registered: February 2010
Location: Baden Switzerland
Member

That depends on the configuration of your firefox/ie. In firefox you can define to open a new Tab instead of a new window. Same in IE. See the screenshots for the options.
index.php/fa/15441/0/
index.php/fa/15442/0/
Greetings
Stephan
  • Attachment: Firefox.png
    (Size: 43.08KB, Downloaded 172 times)
  • Attachment: IE.png
    (Size: 131.26KB, Downloaded 173 times)
Re: Scout RAP external html [message #1066368 is a reply to message #1066354] Tue, 02 July 2013 07:10 Go to previous messageGo to next message
Li Hao is currently offline Li Hao
Messages: 28
Registered: August 2011
Junior Member
I have both setting for IE and firefox, both still open in new window. Firefox 21 and IE 10.
Re: Scout RAP external html [message #1066371 is a reply to message #1066368] Tue, 02 July 2013 07:30 Go to previous messageGo to next message
Stephan Leicht Vogt is currently offline Stephan Leicht Vogt
Messages: 99
Registered: February 2010
Location: Baden Switzerland
Member

You're right. I just checked the code and it opens as default a new window for http-links. But you can overwrite this in your RwtEnvironment:
public class WebStandaloneRwtEnvironment extends AbstractStandaloneRwtEnvironment {

  public WebStandaloneRwtEnvironment() {
    super(Activator.getDefault().getBundle(), ClientSession.class);
  }

  protected BrowserWindowHandler createBrowserWindowHandler() {
    return new TabbedBrowserWindowHandler();
  }
}

@SuppressWarnings("restriction")
public class TabbedBrowserWindowHandler extends BrowserWindowHandler {
  private static IScoutLogger LOG = ScoutLogManager.getLogger(TabbedBrowserWindowHandler.class);

  @Override
  public void openLink(String link) {
    if (link == null) {
      return;
    }
    if (isHttpLink(link)) {
      openLinkInNewBrowserTab(link);
    }
    else {
      super.openLink(link);
    }
  }

  public void openLinkInNewBrowserTab(String link) {
    if (!isHttpLink(link)) {
      return;
    }

    // Code from http://www.eclipse.org/forums/index.php/mv/msg/38108/999310/#msg_999310
    JSExecutor.executeJS("window.open('" + link + "');");
  }
}


Hope that helps. Smile

Greetings
Stephan
Re: Scout RAP external html [message #1066543 is a reply to message #1066371] Wed, 03 July 2013 01:51 Go to previous messageGo to next message
Li Hao is currently offline Li Hao
Messages: 28
Registered: August 2011
Junior Member
The code work for firefox 21.0, but IE 10 still open in new window
Re: Scout RAP external html [message #1066612 is a reply to message #1066543] Wed, 03 July 2013 08:38 Go to previous messageGo to next message
Stephan Leicht Vogt is currently offline Stephan Leicht Vogt
Messages: 99
Registered: February 2010
Location: Baden Switzerland
Member

As I copied the javascript code from the RAP Forum (http://www.eclipse.org/forums/index.php/mv/msg/38108/999310/#msg_999310) I would try to find or get an answer there. I'm sorry that I can't help you further.
Re: Scout RAP external html [message #1066717 is a reply to message #1066612] Wed, 03 July 2013 23:11 Go to previous message
Li Hao is currently offline Li Hao
Messages: 28
Registered: August 2011
Junior Member
Thanks. I think should be ok at this moment, I will try to find out more javascript myself.
Previous Topic:Forcing a scout client to use a specific language
Next Topic:Multi Tenancy
Goto Forum:
  


Current Time: Fri Apr 18 22:08:29 EDT 2014

Powered by FUDForum. Page generated in 0.01714 seconds