com.ibm.mashups.iwidget
Interface iContext


public iContext

This interface defines methods that the iWidget can use to interact with the iContext. An iContext instance is created specifically for each iWidget instance and a reference will be set in iWidget encapsulation object. Thus within iWidget encapsulation class, iContext should be referred to by using "this.iContext"

    var root = this.iContext.getRootElement();


Field Summary
 Object constants
           Defines constants available in iContext.
 io io
           This object provides access to io service. io service is accessible by using "this.iContext.io".
 iEvents iEvents
           This object provides access to events service. event service is accessible by using "this.iContext.iEvents".
 
Method Summary
 String getWidgetId()
           This method returns the unique identifier for this instance of the iWidget in the current evironment (usually a web page).
 DOMElement getRootElement()
           Returns the iContext supplied element containing the content for the current mode of the iwidget such that the iWidget can easily do things such as search its own markup.
 DOMElement getElementById(String id, DOMElement root)
           This method provides the same semantics as the DOM method with the same name, but restricts the search to the iWidget's markup rather than the entire page
 ManagedItemSet getiWidgetAttributes()
           This method returns the ManagedItemSet that provides access to the iWidget's customization attributes.
 ItemSet getItemSet(String name, Boolean isPrivate)
           This method returns an ItemSet corresponding to the requested name.
 ShareableItemSet getShareableItemSet(String name)
           This method returns an ShareableItemSet corresponding to the requested name.
 void requires(String globalid, String version, String uri, Object cb, String mimeType)
           Provides means for iWidget to declare dependency on set of shared resource support dynamic loads in asynchronous manner.
 Object iScope()
           This method returns an instance of type Object which was initialized prior to the loading of the iWidget (either as a generic Object or an instance of the encapsulation Object ) .
 String processMarkup(String markup)
           This method requests the iContext to process the markup such that it can be inserted into the iWidget's markup and properly interact with the page.
 void processiWidgets(DOMNode root)
           This method requests the iContext to process the subtree under the supplied node for the purpose of resolving and instantiating any referenced iWidgets.
 DOMElement[] getElementByClass(String classname, DOMElement root)
           This method returns an array of Elements within the iWidget's markup which have the supplied value as one of those specified by the Element's "class" attribute.
 ManagedItemSet getUserProfile()
           This method returns the ManagedItemSet that provides access to the user's profile data.
 ManagedItemSet getiDescriptor()
           This method returns the ManagedItemSet that provides access to iWidget's descriptive items.
 

Field Detail

constants

Object constants
Defines constants available in iContext.
Constants defined within iContext can be referred as follows:

    this.iContext.constants.mode.VIEW
    this.iContext.constants.mode.EDIT
    this.iContext.constants.mode.PERSONALIZE
   this.iContext.constants.mode.HELP
   this.iContext.constants.ATTRIBUTES
   this.iContext.constants.IDESCRIPTOR
   this.iContext.constants.USERPROFILE


io

io io
This object provides access to io service. io service is accessible by using "this.iContext.io".


iEvents

iEvents iEvents
This object provides access to events service. event service is accessible by using "this.iContext.iEvents".

Method Detail

getWidgetId

String getWidgetId()
This method returns the unique identifier for this instance of the iWidget in the current evironment (usually a web page).

Returns:
widgetId unique identifier of the iWidget. return null if element is not available.

getRootElement

DOMElement getRootElement()
Returns the iContext supplied element containing the content for the current mode of the iwidget such that the iWidget can easily do things such as search its own markup.

Returns:
rootElement of the iWidget. return null if element is not available.

getElementById

DOMElement getElementById(String id,
                          DOMElement root)
This method provides the same semantics as the DOM method with the same name, but restricts the search to the iWidget's markup rather than the entire page

Parameters:
id - element id. Must not be null.
root - optional DOMElement to define a search scope, it will search in the scope of current active mode if root is not provided.
Returns:
return the element, or null if element is not found.

getiWidgetAttributes

ManagedItemSet getiWidgetAttributes()
This method returns the ManagedItemSet that provides access to the iWidget's customization attributes. If there is no ManagedItemSet related to the iWidget's customization attributes, this method MUST create an empty set and return it.

Returns:
return the ManagedItemSet or empty ManagedItemSet if no customization attributes is found.

getItemSet

ItemSet getItemSet(String name,
                   Boolean isPrivate)
This method returns an ItemSet corresponding to the requested name. If it does not already exist, an ItemSet will be created and associated with the supplied name.

Parameters:
name - name of ItemSet. Must not be null.
isPrivate - deprecated,please use getShareableItemSet()if it's a ShareableItemSet.
Returns:
return the requested ItemSet or null if access is denied.

getShareableItemSet

ShareableItemSet getShareableItemSet(String name)
This method returns an ShareableItemSet corresponding to the requested name. If it does not already exist, an ItemSet will be created and associated with the supplied name.

Parameters:
name - name of ItemSet. Must not be null.
Returns:
return the requested ItemSet or null if access is denied.

requires

void requires(String globalid,
              String version,
              String uri,
              Object cb,
              String mimeType)
Provides means for iWidget to declare dependency on set of shared resource support dynamic loads in asynchronous manner. JS and CSS resources are supported.

Parameters:
globalid - globalid of the Item that needs to be loaded. Must not be null.
version - optional
uri - uri of the resource. Must not be null.
cb - optional
mimeType - optional

iScope

Object iScope()
This method returns an instance of type Object which was initialized prior to the loading of the iWidget (either as a generic Object or an instance of the encapsulation Object ) . Its purpose is to support proper encapsulation of the iWidget's assets (variables and methods) such that multiple instances of the iWidget can be loaded into a single page's DOM without stepping on each other. So iWidget resources can refer to any functions that's defined within iWidget encapsulation object by using iContext.iScope().fn();

Returns:
return an instance of the encapsulation class or return a generic object

processMarkup

String processMarkup(String markup)
This method requests the iContext to process the markup such that it can be inserted into the iWidget's markup and properly interact with the page. (i.e. all the iContext reference in the markup needs to be properly namespaced). Where, when and how the markup is inserted into the page is the responsibility of the iWidget.

Parameters:
markup - markupString that needs to be processed. Must not be null.
Returns:
On success this method MUST return the processed markup while on failure it MUST return null

processiWidgets

void processiWidgets(DOMNode root)
This method requests the iContext to process the subtree under the supplied node for the purpose of resolving and instantiating any referenced iWidgets.

Parameters:
root - root element of the subtree. Must not be null.

getElementByClass

DOMElement[] getElementByClass(String classname,
                               DOMElement root)
This method returns an array of Elements within the iWidget's markup which have the supplied value as one of those specified by the Element's "class" attribute.

Parameters:
classname - name of class attribute. Must not be null.
root - root element of the subtree. Must not be null
Returns:
return an array of elements

getUserProfile

ManagedItemSet getUserProfile()
This method returns the ManagedItemSet that provides access to the user's profile data.

Returns:
if there is no ManagedItemSet related to the user's profile, this method creates an empty set and returns it. If access to the user's profile is denied, this method returns null.

getiDescriptor

ManagedItemSet getiDescriptor()
This method returns the ManagedItemSet that provides access to iWidget's descriptive items.

Returns:
If there is no ManagedItemSet related to the iWidget's descriptive items this method creates an empty set and returns it..


Copyright IBM Corp. 2010 All Rights Reserved.