Class finesse.restservices.RestBase
JavaScript representation of a REST object. Also exposes methods to operate
on the object against the server. This object is typically extended into individual
REST Objects (like Dialog, User, etc...), and shouldn't be used directly.
Defined in: finesse.js.
Constructor Attributes | Constructor Name and Description |
---|---|
finesse.restservices.RestBase(id, callbacks, restObj)
|
Field Attributes | Field Name and Description |
---|---|
Default ajax request timout value
|
|
Number that represents the REST Response status that is returned.
|
Method Attributes | Method Name and Description |
---|---|
addHandler(notifierType, callback, scope)
Adds an handler to this object.
|
|
getData()
Gets the data for this object.
|
|
getId()
Getter for the id of this RestBase
|
|
getProperty(obj, property)
Gets a property from the object.
|
|
Append additional query parameter in the rest url
|
|
hasProperty(obj, property)
Determines if the object has a particular property.
|
|
isLoaded()
Utility method gating any operations that require complete instantiation
|
|
refresh(retries)
Force an update on this object.
|
|
removeHandler(notifierType, callback)
Removes a handler from this object.
|
Class Detail
finesse.restservices.RestBase(id, callbacks, restObj)
- Parameters:
- {String} id
- The ID that uniquely identifies the REST object.
- {Object} callbacks
- An object containing callbacks for instantiation and runtime Callback to invoke upon successful instantiation, passes in REST object.
- {Function} callbacks.onLoad(this)
- Callback to invoke upon loading the data for the first time.
- {Function} callbacks.onChange(this)
- Callback to invoke upon successful update object (PUT)
- {Function} callbacks.onAdd(this)
- Callback to invoke upon successful update to add object (POST)
- {Function} callbacks.onDelete(this)
- Callback to invoke upon successful update to delete object (DELETE)
- {Function} callbacks.onError(rsp)
- Callback to invoke on update error (refresh or event)
as passed by finesse.restservices.RestBase.restRequest()
{
status: {Number} The HTTP status code returned
content: {String} Raw string of response
object: {Object} Parsed object of response
error: {Object} Wrapped exception that was caught
error.errorType: {String} Type of error that was caught
error.errorMessage: {String} Message associated with error
} - {RestBase} restObj Optional
- A RestBase parent object which this object has an association with.
Field Detail
ajaxRequestTimeout
Default ajax request timout value
restResponseStatus
Number that represents the REST Response status that is returned. Only
set if keepRestResponse is set to true.
Method Detail
addHandler(notifierType, callback, scope)
Adds an handler to this object.
If notifierType is 'load' and the object has already loaded, the callback is invoked immediately
// Handler for additions to the Dialogs collection object. // When Dialog (a RestBase object) is created, add a change handler. _handleDialogAdd = function(dialog) { dialog.addHandler('change', _handleDialogChange); }
- Parameters:
- {String} notifierType
- The type of notifier to add to ('load', 'change', 'add', 'delete', 'error')
- {Function} callback
- The function callback to invoke.
- scope
getBaseRestUrl()
{Object}
getData()
Gets the data for this object.
- Returns:
- {Object} which is contained in data
{String}
getId()
Getter for the id of this RestBase
- Returns:
- {String} The id of this RestBase
{Property Value}
getProperty(obj, property)
Gets a property from the object.
- Parameters:
- obj
- is the object to examine
- property
- is the property to get
- Returns:
- {Property Value} or {Null} if not found
getRestUrlAdditionalParameters()
Append additional query parameter in the rest url
{Boolean}
hasProperty(obj, property)
Determines if the object has a particular property.
- Parameters:
- obj
- is the object to examine
- property
- is the property to check for
- Returns:
- {Boolean}
{finesse.restservices.RestBase}
isLoaded()
Utility method gating any operations that require complete instantiation
- Throws:
- Error If this object was not fully instantiated yet
- Returns:
- {finesse.restservices.RestBase} This RestBase object to allow cascading
{Object}
refresh(retries)
Force an update on this object. Since an asynchronous GET is performed,
it is necessary to have an onChange handler registered in order to be
notified when the response of this returns.
- Parameters:
- {Integer} retries
- The number or retry attempts to make.
- Returns:
- {Object}
{
abort: {function} Function that signifies the callback handler to NOT process the response of the asynchronous request
}
removeHandler(notifierType, callback)
Removes a handler from this object.
- Parameters:
- {String} notifierType
- The type of notifier to remove ('load', 'change', 'add', 'delete', 'error')
- {Function} callback
- The function to remove.