Tuesday, December 18, 2012

Re: Equivalent to javascript confirmdialog ind GWT

You could use event.preventDefault() in onWindowClosing method,
display custom dialog box and if user confirmed close logout him.

Best,
Milan

On Monday, December 17, 2012 5:10:52 PM UTC+1, Dominic Warzok wrote:
The solution is posted her on Stackoverflow

And here is my code (it's only a extract of the full class) :

public class MainPresenter<V extends MainView>
    extends BasicPresenter<V>
    implements HistoryTokens, MainViewControl, LoginEventHandler, Window.ClosingHandler,
    CloseHandler<Window>
{
 ....
 Window.addWindowClosingHandler( this );
    Window.addCloseHandler( this );

....

  /**
   * Diese Methode wird naufgerufen wenn das Browsertab geschlossen werden soll
   */
  @Override
  public void onWindowClosing( ClosingEvent in_event )
  {
    if ( model.isUserlogin() )
    {
      in_event.setMessage( CONSTANTS.web_client_MainPresenter_AenderungenSpeichernHinweis() );
    }
  }

  /**
   * Diese Methode wird naufgerufen wenn das Browsertab geschlossen wird
   */
  @Override
  public void onClose( CloseEvent<Window> event )
  {
    if ( model.isUserlogin() )
    {
      camWebServiceAsync.logout( new AsyncCallback<Void>()
      {

        @Override
        public void onSuccess( Void in_result )
        {
          
        }

        @Override
        public void onFailure( Throwable in_caught )
        {
        }
      } );
    }
  }

}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/8PHJaoorKCQJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment