Class CancellationController

java.lang.Object
com.smartgwt.client.core.BaseClass
com.smartgwt.client.util.CancellationController
All Implemented Interfaces:
HasHandlers

public class CancellationController extends BaseClass
Provides a mechanism for canceling asynchronous operations.
  • Constructor Details

    • CancellationController

      public CancellationController()
    • CancellationController

      public CancellationController(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static CancellationController getOrCreateRef(JavaScriptObject jsObj)
    • setJavaScriptObject

      public void setJavaScriptObject(JavaScriptObject jsObj)
      Overrides:
      setJavaScriptObject in class BaseClass
    • create

      public JavaScriptObject create()
      Specified by:
      create in class BaseClass
    • isCreated

      public boolean isCreated()
      Overrides:
      isCreated in class BaseClass
    • getJsObj

      public JavaScriptObject getJsObj()
      Overrides:
      getJsObj in class BaseClass
    • getOrCreateJsObj

      public JavaScriptObject getOrCreateJsObj()
      Overrides:
      getOrCreateJsObj in class BaseClass
    • getCanceled

      public Boolean getCanceled() throws IllegalStateException
      Whether cancel() has been called.

      Note : This method should be called only after the underlying component has been created.

      Returns:
      Current canceled value. Default value is false
      Throws:
      IllegalStateException - if the underlying component has not yet been created.
    • getCancellationReason

      public String getCancellationReason() throws IllegalStateException
      The reason, if any, passed to the first call to cancel().

      Note : This method should be called only after the underlying component has been created.

      Returns:
      Current cancellationReason value. Default value is null
      Throws:
      IllegalStateException - if the underlying component has not yet been created.
      See Also:
    • cancel

      public Boolean cancel()
      Requests cancellation of all asynchronous operations that are polling canceled or observing this method. Also cancels any sub-CancellationControllers of this CancellationController that are not already canceled.

      this.cancellationReason is set to the provided reason only on the first call to cancel().

      For observers of this method, the recommended practice is to capture the returnVal and only perform the cancellation steps if the returnVal was true. This is because it could happen that cancel() is called a second time before the observers finish.

      Returns:
      true if this was the first call to cancel(); false otherwise.
    • cancel

      public Boolean cancel(String reason)
      Requests cancellation of all asynchronous operations that are polling canceled or observing this method. Also cancels any sub-CancellationControllers of this CancellationController that are not already canceled.

      this.cancellationReason is set to the provided reason only on the first call to cancel().

      For observers of this method, the recommended practice is to capture the returnVal and only perform the cancellation steps if the returnVal was true. This is because it could happen that cancel() is called a second time before the observers finish.

      Parameters:
      reason - A reason for cancellation. See HTMLString
      Returns:
      true if this was the first call to cancel(); false otherwise.
    • createSubController

      public CancellationController createSubController()
      Creates a new CancellationController which is canceled whenever this CancellationController is canceled.

      Note that the sub-CancellationController may be independently canceled before this parent CancellationController is canceled.

      Returns:
      a new CancellationController that is canceled whenever this CancellationController is canceled.