Package com.smartgwt.client.util

# 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.

- ## Field Summary

  ### Fields inherited from class com.smartgwt.client.core.BaseClass

  `config, configOnly, factoryCreated, factoryProperties, id, scClassName`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CancellationController()`
  `CancellationController(JavaScriptObject jsObj)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Boolean`
  `cancel()`
  Requests cancellation of all asynchronous operations that are polling `canceled` or observing this method.
  `Boolean`
  `cancel(String reason)`
  Requests cancellation of all asynchronous operations that are polling `canceled` or observing this method.
  `JavaScriptObject`
  `create()`
  `CancellationController`
  `createSubController()`
  Creates a new `CancellationController` which is canceled whenever this `CancellationController` is canceled.
  `Boolean`
  `getCanceled()`
  Whether `cancel()` has been called.
  `String`
  `getCancellationReason()`
  The reason, if any, passed to the first call to `cancel()`.
  `JavaScriptObject`
  `getJsObj()`
  `JavaScriptObject`
  `getOrCreateJsObj()`
  `static CancellationController`
  `getOrCreateRef(JavaScriptObject jsObj)`
  `boolean`
  `isCreated()`
  `void`
  `setJavaScriptObject(JavaScriptObject jsObj)`

  ### Methods inherited from class com.smartgwt.client.core.BaseClass

  `addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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:
      - `HTMLString`

  - ### cancel

    public Boolean cancel()
    Requests cancellation of all asynchronous operations that are polling `canceled` or observing this method. Also cancels any `sub-`CancellationController``s 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-`CancellationController``s 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.