com.smartgwt.client.util

## Class CancellationController

- java.lang.Object
- - com.smartgwt.client.core.BaseClass
  - - com.smartgwt.client.util.CancellationController

- All Implemented Interfaces:
    com.google.gwt.event.shared.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 and Description
    `CancellationController()`
    `CancellationController(com.google.gwt.core.client.JavaScriptObject jsObj)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Boolean` | `cancel()` Requests cancellation of all asynchronous operations that are polling `canceled` or observing this method.
    `java.lang.Boolean` | `cancel(java.lang.String reason)` Requests cancellation of all asynchronous operations that are polling `canceled` or observing this method.
    `com.google.gwt.core.client.JavaScriptObject` | `create()`
    `CancellationController` | `createSubController()` Creates a new `CancellationController` which is canceled whenever this `CancellationController` is canceled.
    `java.lang.Boolean` | `getCanceled()` Whether `cancel()` has been called.
    `java.lang.String` | `getCancellationReason()` The reason, if any, passed to the first call to `cancel()`.
    `com.google.gwt.core.client.JavaScriptObject` | `getJsObj()`
    `com.google.gwt.core.client.JavaScriptObject` | `getOrCreateJsObj()`
    `static CancellationController` | `getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `boolean` | `isCreated()`
    `void` | `setJavaScriptObject(com.google.gwt.core.client.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 Detail

    - #### CancellationController

          public CancellationController()

    - #### CancellationController

          public CancellationController(com.google.gwt.core.client.JavaScriptObject jsObj)

  - ### Method Detail

    - #### getOrCreateRef

          public static CancellationController getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### setJavaScriptObject

          public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)

      Overrides:
        `setJavaScriptObject` in class `BaseClass`

    - #### create

          public com.google.gwt.core.client.JavaScriptObject create()

      Specified by:
        `create` in class `BaseClass`

    - #### isCreated

          public boolean isCreated()

      Overrides:
        `isCreated` in class `BaseClass`

    - #### getJsObj

          public com.google.gwt.core.client.JavaScriptObject getJsObj()

      Overrides:
        `getJsObj` in class `BaseClass`

    - #### getOrCreateJsObj

          public com.google.gwt.core.client.JavaScriptObject getOrCreateJsObj()

      Overrides:
        `getOrCreateJsObj` in class `BaseClass`

    - #### getCanceled

          public java.lang.Boolean getCanceled()
                                        throws java.lang.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:
        `java.lang.IllegalStateException` - if the underlying component has not yet been created.

    - #### getCancellationReason

          public java.lang.String getCancellationReason()
                                                 throws java.lang.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:
        `java.lang.IllegalStateException` - if the underlying component has not yet been created.
      See Also:
        `HTMLString`

    - #### cancel

          public java.lang.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 java.lang.Boolean cancel(java.lang.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.