How I can control flow of execution in GWT?

101 Views Asked by At

If you have ever used Window.alert("msg"); API in GWT to show popup, I am not sure but the call to this API pauses the code execution until a user action is taken (cliking the ok button), Simillar to that i have created a custom popup, when it is shown i don't want the code to execute further till any user input in received on the popup, How can i pause the code execution further? Assume :- //Some Code

MY Popup (Here i want to wait till a user action is received.)

//Some code

I read somewhere to use Synchronized key word but that didn't work either,Do you have answer to this. How GWT compiler sees "Synchronized" keyword does it ignores the keyword?

1

There are 1 best solutions below

0
Knarf On

Create something like a ConfirmCallBack that you fire when the "OK" button (or whatever) is clicked in the popuppanel.

//method in your own popup class
public static void confirm(String message,  ConfirmCallBack confirmCallBack)
{
    Button confirmButton = new Button(confirmButtonText, event ->
  {
     confirmCallBack.callback(true);
     //hide popup
  });
}

Than also have the ConfirmCallBack interface like

public interface ConfirmCallBack
{
   void callback(boolean result);
}

Then call your own popup like

MyPopup.confirm("Hello world", result ->
{
   if (result)
   {
      //my code to be executed after clicking the ok button
   }
}