Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Redirect browser after close workbench
Redirect browser after close workbench [message #635069] Mon, 25 October 2010 14:53 Go to next message
Sergey Kuznetsov is currently offline Sergey KuznetsovFriend
Messages: 29
Registered: July 2009
Junior Member
Hi,

Is it possible to redirect browser after workbench being closed to some html
(bundle resource)?

Thanks,
Sergey.
Re: Redirect browser after close workbench [message #635928 is a reply to message #635069] Thu, 28 October 2010 15:51 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Sergey,
yes it possible, but currently only by using an internal RAP classes or
custom widget. Using internal RAP classes is NOT recommended, as they
are subject to change in any time, but this is the easier way to do it.
Without testing myself you could try:
----
String jscode = "window.location.href = 'http://www.eclipse.org';";
JSExecutor.executeJS( jsCode );
----
You could use this code in the main shell listener
ShellListener#shellClosed for example.
HTH,
Ivan

On 10/25/2010 5:53 PM, Sergey Kuznetsov wrote:
> Hi,
>
> Is it possible to redirect browser after workbench being closed to
> some html (bundle resource)?
>
> Thanks,
> Sergey.
Re: Redirect browser after close workbench [message #635941 is a reply to message #635069] Thu, 28 October 2010 16:29 Go to previous messageGo to next message
Austin Riddle is currently offline Austin RiddleFriend
Messages: 128
Registered: July 2009
Senior Member
Hi Sergey,

This is what we use for redirecting to a logout page.

Just override postShutdown() in your workbench advisor:


@Override
   public void postShutdown()
   {
      super.postShutdown();
      final Display display = Display.getCurrent();
      RWT.getLifeCycle().addPhaseListener( new PhaseListener() {
         
         private static final long serialVersionUID = 1L;
         
         @SuppressWarnings("restriction")
         public void afterPhase( PhaseEvent event ) {
            if( Display.getCurrent() == null || display == Display.getCurrent() ) {
               try {
                  // Uses a non-public API, but currently this is the only solution
                  HtmlResponseWriter writer
                  = ContextProvider.getStateInfo().getResponseWriter();
                  String url = "theme/logout-confirmation.html";
                  writer.write( "window.location.href=\"" + url  + "\";" );
                  RWT.getRequest().getSession().setMaxInactiveInterval(1);
               } catch( IOException e ) {
                  e.printStackTrace();
               }
               RWT.getLifeCycle().removePhaseListener( this );
            }
         }
         
         public PhaseId getPhaseId() {
            return PhaseId.ANY;
         }
         
         public void beforePhase(PhaseEvent event) {};
         
      } );
   }


Keep in mind the warning that Ivan gave, this does use internal API, but it may be appropriate for your situation.

Hope this helps.

[Updated on: Thu, 28 October 2010 16:33]

Report message to a moderator

Re: Redirect browser after close workbench [message #635973 is a reply to message #635928] Thu, 28 October 2010 19:10 Go to previous messageGo to next message
Sergey Kuznetsov is currently offline Sergey KuznetsovFriend
Messages: 29
Registered: July 2009
Junior Member
thanks a lot, that works!

28.10.10 17:51, Ivan Furnadjiev пишет:
> Hi Sergey,
> yes it possible, but currently only by using an internal RAP classes or
> custom widget. Using internal RAP classes is NOT recommended, as they
> are subject to change in any time, but this is the easier way to do it.
> Without testing myself you could try:
> ----
> String jscode = "window.location.href = 'http://www.eclipse.org';";
> JSExecutor.executeJS( jsCode );
> ----
> You could use this code in the main shell listener
> ShellListener#shellClosed for example.
> HTH,
> Ivan
>
> On 10/25/2010 5:53 PM, Sergey Kuznetsov wrote:
>> Hi,
>>
>> Is it possible to redirect browser after workbench being closed to
>> some html (bundle resource)?
>>
>> Thanks,
>> Sergey.
Re: Redirect browser after close workbench [message #635974 is a reply to message #635941] Thu, 28 October 2010 19:11 Go to previous message
Sergey Kuznetsov is currently offline Sergey KuznetsovFriend
Messages: 29
Registered: July 2009
Junior Member
Thanks! A good point for me to start.

28.10.10 18:29, Austin Riddle пишет:
> Hi Sergey,
>
> This is what we use for redirecting to a logout page:
>
>
>
> @Override
> public void postShutdown()
> {
> super.postShutdown();
> final Display display = Display.getCurrent();
> RWT.getLifeCycle().addPhaseListener( new PhaseListener() {
> private static final long serialVersionUID = 1L;
> @SuppressWarnings("restriction")
> public void afterPhase( PhaseEvent event ) {
> if( Display.getCurrent() == null || display == Display.getCurrent() ) {
> try {
> // Uses a non-public API, but currently this is the only solution
> HtmlResponseWriter writer
> = ContextProvider.getStateInfo().getResponseWriter();
> String url = "theme/logout-confirmation.html";
> writer.write( "window.location.href=\"" + url + "\";" );
> RWT.getRequest().getSession().setMaxInactiveInterval(1);
> } catch( IOException e ) {
> e.printStackTrace();
> }
> RWT.getLifeCycle().removePhaseListener( this );
> }
> }
> public PhaseId getPhaseId() {
> return PhaseId.ANY;
> }
> public void beforePhase(PhaseEvent event) {};
> } );
> }
>
>
> Hope this helps.
Previous Topic:Own favicon and title for application when using RAP business design
Next Topic:circular dependency in RAP
Goto Forum:
  


Current Time: Fri Apr 19 21:54:32 GMT 2024

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

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

Back to the top