I have an Eclipse RAP 2.3 application with two entry points, say /first
and /second
.
In the GUI of the first entry point, there is a button with which I would like to open the second entry point in a new browser tab. The event handler of that button is currently
UrlLauncher launcher = RWT.getClient().getService( UrlLauncher.class );
launcher.openURL( "/second");
This already doesn't work when the application is deployed as myapp.war
in a Tomcat web server (should then be /myapp/second
).
My questions:
- What's the best way to determine the URL to open within the event handler?
- Do I have to fetch the
HttpServletRequest
, get the context path and so some string manipulation? - Is it actually safe to call
RWT.getRequest()
at this point?
Update
According to Rüdiger's comment I can acquire the context path in two different ways.
The first approach is
RWT.getRequest().getContextPath();
where
RWT.getRequest()
is documented withThis method is not recommended
Secondly, I could obtain it with
ApplicationContextImpl ac = (ApplicationContextImpl) RWT.getApplicationContext(); String contextPath = ac.getServletContext().getContextPath();
where the IDE displays the warning
Discouraged access: The type ApplicationContextImpl is not accessible due to restriction on required library ...\org.eclipse.rap.rwt_2.3.2.20150128-1013.jar
Despite the warning, it still works when deploying a WAR file with OSGi bundles to Tomcat.
So, in both cases there is some kind of warning, which makes the solutions look rather like workarounds.