Class: AbstractExecutable

bcdui.core. AbstractExecutable

The abstract executable class is a base class for asynchronous operating status-based classes in BCD-UI library. It offers a basic set of methods that these classes share. Most methods deal with status handling, transitions, listeners and synchronization.
Most common implementations are: bcdui.core.StaticModelbcdui.core.SimpleModel

abstractnew bcdui.core.AbstractExecutable(args)

The constructor which must be called by all sub-classes. It initializes the listeners, status and id fields. This class is abstract and not meant to be instantiated directly
Name Type Description
args Object optional Parameter object
Name Type Description
id string optional A unique id for declarative contexts
bcdPreInit function optional a function which can be used to execute code before any super code of derived classes
Throws:
Error An Error is thrown if id is not unique, i.e. an object with the same id is already registered.

Members

constantidstring

A globally unique id of the object. DataProviders do also register themselves at bcdui.factory.objectRegistry when an id is provided to the constructor. This id is only needed in declarative contexts, like jsp or, when a DataProvider is accessed in a xPath like . If not provided in the constructor, a random id starting with 'bcd' is set, but the object is not automatically registered.

Methods

addStatusListener(args)

Listen for any status to be reached. For use cases with the ready status (by far the most common), see onReady() and onceReady() convenience functions.
Name Type Description
args function | StatusListener | AddStatusListenerParam Either a function executed on all status transitions or a parameter map AddStatusListenerParam

execute(doesRefresh)

Executes the process implemented by the concrete sub-class.
Name Type Default Description
doesRefresh boolean true optional Set this parameter to "false" if this method should do nothing when the object is already in the ready status. The default is "true" meaning that the process is re-started when it is currently ready.

abstractgetFailedStatus(){Array.<bcdui.core.Status>}

Getter for the list of error statuses of this class. This implementation returns an empty list.
Returns:
Type Description
Array.<bcdui.core.Status> The status objects corresponding to failures in the object's process.
Getter for the ready status of the instance. This status is a final state defined by each sub-class which is reached when the process has finished normally.
Returns:
Type Description
bcdui.core.Status The status object indicating that the process belonging to this class is finished.
Getter for the status of this object. See bcdui.core.status for possible return values.
Returns:
Type Description
bcdui.core.Status The current status.

hasFailed(){boolean}

Tests if the object has reached a failure status. These status codes are returned by the "getFailedStatus" method.
Returns:
Type Description
boolean True, if the object's process has failed.

isReady(){boolean}

Tests if the current state is the readyStatus. This status is the same status as returned by "getReadyStatus".
Returns:
Type Description
boolean True, if the object is ready.

onceReady(listenerObject)

Name Type Description
listenerObject function | OnceReadyParam Either a function to be called on ready status (i.e. onSuccess) or a parameter map OnceReadyParam. To listen for other states see addStatusListener()
Example
myModel.onceReady({onSuccess: myCallback, executeIfNotReady: true})

onReady(listenerObject)

Name Type Description
listenerObject function | OnReadyParam Either a function to be called on ready status (i.e. onSuccess) or a parameter map OnReadyParam. To listen for other states see addStatusListener()
Example
myModel.onReady({onSuccess: function(){ console.log("ready") }, executeIfNotReady: true, onlyFuture: true})

removeStatusListener(args)

Name Type Description
args function | StatusListener | RemoveStatusListenerParam The listener to be removed. This can either be a function or a StatusListener or a parameter map RemoveStatusListenerParam.
Makes a transition from the current status to the new status if they are not equal. After the status is changed it fires the status event to the registered listeners.

Usually this method will only be called by the library but you can use it to re-trigger an action. For available statuses and their effect, see the concrete class,

Name Type Description
args bcdui.core.Status Either a Status object or a parameter map with a property "status" holding a Status object.

abstracttoString(){string}

Returns:
Type Description
string Debug string with this class and its id.