-
-
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.
-
-
Returns:
Type |
Description |
string
|
Human readable message, which DataProviders, this DataProvider depends on, are not currently in ready state |
-
-
Returns:
Type |
Description |
string
|
Human readable message about the current state state |
-
-
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. |
-
-
asynchronously fetch data for this data provider.
Returns:
Type |
Description |
Promise
|
resolving once data has been loaded, first argument is this instance |
Example
new bcdui.core.SimpleModel("data.xml").fetchData().then((dp)=>{ console.info(dp.getData()); })
-
-
This informs modification listeners, registered via
onChange(args), that a change set was completed
and data is consistent again.
Example
// Use of data modification events
var model = new bcdui.core.StaticModel({ data: { value: 3 } });
model.execute();
model.onChange( function(m) {
console.log(m.getData().value);
});
model.getData().value ++;
model.fire(); // console prints '4'
-
-
Access to the data of this DataProvider for read and modification access
Returns:
Type |
Description |
*
|
The data provided by the specific sub-class. |
-
-
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. |
-
-
Returns:
Type |
Description |
string
|
The name of the data provider. This name should be unique
within the scope it is used and is usually not globally unique (as the id). |
-
-
Returns:
Type |
Description |
bcdui.core.Status
|
Returns the final state indicating the the value is available. |
-
-
Getter for the status of this object. See
bcdui.core.status for possible return values.
Returns:
-
-
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. |
-
-
True, if DataProvider is ready and there are no uncommitted write transactions,
see
isReady() and
fire().
Returns:
-
-
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. |
-
-
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})
-
inherited
onChange(listenerObject, trackingXPath)
-
Name |
Type |
Description |
listenerObject |
function
|
OnChangeParam
|
Either a function to be called after changes or a parameter map OnChangeParam. Listeners can be removed with removeDataListener() |
trackingXPath |
string
|
optional
xPath to monitor to monitor for changes |
-
-
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})
-
-
Convenience method for debugging showing data in a prompt for copy-and-paste
-
-
Reads a single node from a given xPath
Name |
Type |
Description |
xPath |
string
|
xPath to query |
Returns:
single node or null if query fails or source isn't set yet
-
-
Get node list from a given xPath
Name |
Type |
Description |
xPath |
string
|
xPath to query |
Returns:
node list or empty list if query fails or source isn't set yet
-
read(xPath, fillParams, defaultValue)
-
Reads value from a given xPath (or optionally return default value)
Name |
Type |
Description |
xPath |
string
|
xPath pointing to value |
fillParams |
Object
|
optional
array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions |
defaultValue |
string
|
optional
default value in case xPath value does not exist |
Returns:
text value stored at xPath (or null if nothing found and no defaultValue supplied or when source isn't set yet)
-
remove(xPath, fillParams, fire)
-
removes given xPath
Name |
Type |
Default |
Description |
xPath |
string
|
|
xPath pointing to value |
fillParams |
Object
|
|
optional
array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions |
fire |
boolean
|
false
|
optional
if true a fire is triggered to notify data modification listener |
-
-
-
-
-
-
Sends the current data to the original URL
-
-
Serialize dataprovider's data if available
Returns:
String containing the serialized data
-
-
Set the underlying source delayed instead of via the constructor.
The DataProviderHolder does only become ready after the source was set and is or becomes ready.
-
-
Name |
Type |
Description |
args |
Status
|
|
-
-
Returns:
Type |
Description |
string
|
Human readable summary of this class. |
-
write(xPath, fillParams, value, fire)
-
Set a value to on a certain xPath and create the xPath where necessary.
This combines Element.evaluate() for a single node with creating the path where necessary.
It will prefer extending an existing start-part over creating a second one.
After the operation the xPath (with the optional value) is guaranteed to exist (pre-existing or created or extended) and the addressed node is returned.
Name |
Type |
Default |
Description |
xPath |
string
|
|
xPath pointing to the node which is set to the value value or plain xPath to be created if not there.
It tries to reuse all matching parts that are already there. If you provide for example "/n:Root/n:MyElem/@attr1" and there is already "/n:Root/n:MyElem@attr1", then ""/n:Root/n:MyElem" will be "re-used" and get a second attribute attr1.
Many expressions are allowed, for example "/n:Root/n:MyElem[@attr1='attr1Value']/n:SubElem" is also ok.
By nature, some xPath expressions are not allowed, for example using '//' or "/n:Root/n:MyElem/[@attr1 or @attr2]/n:SubElem" is obviously not unambiguous enough and will throw an error.
This method is Wrs aware, use for example '/wrs:Wrs/wrs:Data/wrs:*[2]/wrs:C[3]' as xPath and it will turn wrs:R[wrs:C] into wrs:M[wrs:C and wrs:O], see Wrs format. |
fillParams |
Object
|
|
optional
array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions |
value |
string
|
|
optional
Optional value which should be written, for example to "/n:Root/n:MyElem/@attr" or with "/n:Root/n:MyElem" as the element's text content.
If not provided, the xPath contains all values like in "/n:Root/n:MyElem[@attr='a' and @attr1='b']" or needs none like "/n:Root/n:MyElem" |
fire |
boolean
|
false
|
optional
If true a fire is triggered to inform data modification listeners |
Returns:
The xPath's node (can be null if source isn't set yet or dataProvider isn't ready)