com.ibm.mashups.iwidget.model
Interface WidgetModel


public WidgetModel

WidgetModel interface defines functions that expose information of a widget model.
Global model available to all the page components.
var widgetModel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel();


Method Summary
 IWidgetWrapper find(String id)
           Returns an iWidgetWrapper object which represents a runtime instance of an iWidget object.
 Boolean hasChildren(com.ibm.mashups.iwidget.iWidgetWrapper iWidgetWrapper)
           Returns whether or not the given node has children.
 IWidgetWrapper[] getChildren(IWidgetWrapper iWidgetWrapper, Boolean isNested)
           Returns an array of iWidgetWrapper object.
 IWidgetWrapper getParent(IWidgetWrapper iWidgetWrapper)
           Returns the parent object of the specified iWidgetWrapper object .
 com.ibm.mashups.enabler.Deferred getWidgetDefinitionByUrl(String url)
          Deprecated.  Use getWidgetDefinitionByURL instead.
 com.ibm.mashups.enabler.Deferred getWidgetDefinitionByURL(String url)
           Returns the deferred object used to start this operation and an IWidgetDefinition object is returned when deferred object is executed.
 DeferredOperation commit()
           Commits the modifications applied to this model and all dependent models.
 IWidgetDefinition createIWidgetDefinition(Object json)
           Returns iWidgetDefinition object for the specified JSON object.
 IWidgetWrapper createWidget(Object span)
           Creates a widget and associates it with a span element on the page
 

Method Detail

find

IWidgetWrapper find(String id)
Returns an iWidgetWrapper object which represents a runtime instance of an iWidget object.
Id is the "id" attribute that's defined in microformat. It's used to uniquely identify an iWidget instance on the page.
<span class="iw-iWidget" id="{id}">

Parameters:
id - unique id of an iWidget wrapper. Must not be NULL.
Returns:
an iWidget Wrapper of the required iWidget . iWidget Wrapper represents a runtime instance of an iWidget.

hasChildren

Boolean hasChildren(com.ibm.mashups.iwidget.iWidgetWrapper iWidgetWrapper)
Returns whether or not the given node has children. NOT Implemented.

Parameters:
iWidgetWrapper - parent iWidgetWrapper object. Must not be NULL.
Returns:
returns TRUE if the given node has children.

getChildren

IWidgetWrapper[] getChildren(IWidgetWrapper iWidgetWrapper,
                             Boolean isNested)
Returns an array of iWidgetWrapper object. NOT Implemented.

Parameters:
iWidgetWrapper - parent object .Must not be NULL.
isNested - optional. the default value is TRUE. It returns all the nested iWidgets if it's true. It returns only direct children if it's false.
Returns:
return an array of iWidgetWrapper object .

getParent

IWidgetWrapper getParent(IWidgetWrapper iWidgetWrapper)
Returns the parent object of the specified iWidgetWrapper object .

Parameters:
iWidgetWrapper - iWidgetWrapper object. Must not be NULL.
Returns:
returns parent node or NULL if the node has no parent.

getWidgetDefinitionByUrl

com.ibm.mashups.enabler.Deferred getWidgetDefinitionByUrl(String url)
Deprecated.  Use getWidgetDefinitionByURL instead.

Returns the deferred object used to start this operation and an IWidgetDefinition object is returned when deferred object is executed.
var deferred = widgetModel.getWidgetDefinitionByUrl(url)
deferred.setFinishedCallback(callback,parameters);
deferred.start(false);
here are the callback parameters that will be passed into callback function:
    resource - IWidgetDefinition object
    statuscode - the HTTP status,code of the action .
    params - optional. may use this to pass additional parameters into the callback .
here is a sample implementation of callbackfunction:
    function callback(resource, statuscode, params) {
          if (statuscode == 200) {
          var defObj = resource;
          ... }
          }

Parameters:
url - url to load widget definition. Must not be NULL.
Returns:
a deferred object used to start this operation.
See Also:
IWidgetDefinition

getWidgetDefinitionByURL

com.ibm.mashups.enabler.Deferred getWidgetDefinitionByURL(String url)
Returns the deferred object used to start this operation and an IWidgetDefinition object is returned when deferred object is executed.
var deferred = widgetModel.getWidgetDefinitionByUrl(url)
deferred.setFinishedCallback(callback,parameters);
deferred.start(false);
here are the callback parameters that will be passed into callback function:
    resource - IWidgetDefinition object
    statuscode - the HTTP status,code of the action .
    params - optional. may use this to pass additional parameters into the callback .
here is a sample implementation of callbackfunction:
    function callback(resource, statuscode, params) {
          if (statuscode == 200) {
          var defObj = resource;
          ... }
          }

Parameters:
url - url to load widget definition. Must not be NULL.
Returns:
a deferred object used to start this operation.
See Also:
IWidgetDefinition

commit

DeferredOperation commit()
Commits the modifications applied to this model and all dependent models.

Returns:
a deferred object used to start this operation. The return value when executed through the deferred object is null

createIWidgetDefinition

IWidgetDefinition createIWidgetDefinition(Object json)
Returns iWidgetDefinition object for the specified JSON object.

Parameters:
json - JSON object. Must not be NULL.
Returns:
returns the IWidgetDefinition representation of the JSON object.
See Also:
IWidgetDefinition

createWidget

IWidgetWrapper createWidget(Object span)
Creates a widget and associates it with a span element on the page

Parameters:
span - DOMElement to associate the widget with. Must not be NULL.
Returns:
returns the IWidgetWrapper representation of the JSON object. May be NULL.


Copyright IBM Corp. 2010 All Rights Reserved.