new AbstractWidget()
This is an abstract class; no instances of this class should be created.
- See:
Extends
Method Summary
- clean
- Removes all the rows from the model and reflects the change on the view.
- getValue
- Returns the value from the model for the specified key/field pair.
- parseHtml
- Abstract method.
- removeRow
- Removes a row from the internal model and reflects the change on the view.
- setAutoCleanBehavior
- Utility method that can be used to control part of the behavior of the widget in case it is used as a listener for one or more Subscription instances.
- updateRow
- Updates a row in the internal model and reflects the change on the view.
Inherited Methods
|
onCommandSecondLevelItemLostUpdates |
onCommandSecondLevelSubscriptionError |
onEndOfSnapshot |
onItemLostUpdates |
onSubscriptionError |
Method Detail
-
clean()
-
Removes all the rows from the model and reflects the change on the view.
Lifecycle: once the AbstractWidget#parseHtml method has been called, this method can be used at any time.
Throws:
-
if parseHtml has not been executed yet.
-
-
getValue(key, field) → {String}
-
Returns the value from the model for the specified key/field pair. If the row for the specified key does not exist or if the specified field is not available in the row then null is returned.
Lifecycle: This method can be called at any time.
Parameters:
Name Type Description key
String The key associated with the row to be read. field
String The field to be read from the row. Returns:
The current value for the specified field of the specified row, possibly null. If the value for the specified field has never been assigned in the model, the method also returns null.- Type
- String
-
parseHtml()
-
Abstract method. See subclasses descriptions for details.
-
removeRow(key)
-
Removes a row from the internal model and reflects the change on the view. If no row associated with the given key is found nothing is done.
Lifecycle: once the AbstractWidget#parseHtml method has been called, this method can be used at any time.
Parameters:
Name Type Description key
String The key associated with the row to be removed. Throws:
-
if parseHtml has not been executed yet.
-
-
setAutoCleanBehavior(onFirstSubscribe, onLastUnsubscribe)
-
Utility method that can be used to control part of the behavior of the widget in case it is used as a listener for one or more Subscription instances.
Specifying the two flags it is possible to decide to clean the model and view based on the status (subscribed or not) of the Subscriptions this instance is listening to.Lifecycle: This method can be called at any time.
Parameters:
Name Type Description onFirstSubscribe
boolean If true a AbstractWidget#clean call will be automatically performed if in the list of Subscriptions this instance is listening to there is no Subscription in the subscribed status and an onSubscription is fired by one of such Subscriptions.
As a special case, if in the list of Subscriptions this instance is listening to there is no Subscription in the subscribed status and this instance starts listening to a new Subscription that is already in the subscribed status, then it will be considered as if an onSubscription event was fired and thus a clean() call will be performed.onLastUnsubscribe
boolean If true a AbstractWidget#clean call will be automatically performed if in the list of Subscriptions this instance is listening to there is only one Subscription in the subscribed status and the onUnsubscription for such Subscription is fired.
As a special case, if in the list of Subscriptions this instance is listening to there is only one Subscription in the subscribed status and this instance stops listening to such Subscription then it will be considered as if the onUnsubscription event for that Subscription was fired and thus a clean() call will be performed. -
updateRow(key, newValues)
-
Updates a row in the internal model and reflects the change on the view. If no row associated with the given key is found then a new row is created.
Example usage:myWidget.updateRow("key1", {field1:"val1",field2:"val2"});
Lifecycle: once the AbstractWidget#parseHtml method has been called, this method can be used at any time. If called while an updateRow on the same internal model is still executing (e.g. if called while handling an onVisualUpdate callback), then the new update:
- if pertaining to a different key and/or if called on a Chart instance, will be postponed until the first updateRow execution terminates;
- if pertaining to the same key and if called on a StaticGrid / DynaGrid instance, will be merged with the current one.
Parameters:
Name Type Description key
String The key associated with the row to be updated/added. newValues
Object A JavaScript object containing name/value pairs to fill the row in the mode.
Note that the internal model does not have a fixed number of fields; each update can add new fields to the model by simply specifying them. Also, an update having fewer fields than the current model will have its missing fields considered as unchanged.Throws:
-
if parseHtml has not been executed yet.