Gadget API

From MemberWiki

Jump to: navigation, search

Widget Lifecycle Management

A composition canvas will need the ability to:

  • Create a widget instance and add it to the composition surface.
    • The first release of the IDE specification is not addressing containment.
    • The jsClass attribute in the widget metadata identifies the name of a javascript prototype function for generating the widget instance.
  • Set & Get the values of the published properties of the widget.

Lifecycle Events:

  • onLoad: This event signals that the page has finished loading
  • onUnload: This event signals that the widget is about to be unloaded (commonly due to a page transition).
  • onRemove - This event signals that the a widget instance is being removed from a page. This is different from onUnload in that the canvas is informing the widget instance that it has been removed from the canvas
  • onModeChanged: This event signals that the mode for the widget instance has changed. (view, edit and help modes)
  • onResize: This event signals that the size for the widget instance has changed.

Gadget Interface

Each instance of a widget is represented using a JavaScript object which provides the communication between the host environment and the native widget executing in a given widget toolkit. The optional jsClass attribute of the widget specifies the name of a JavaScript constructor function to be used when instantiating a given widget.

Below is an interface description of the set and get property calls that are required to be implemented by the widget the syntax below does not denote implementation.


Wrapper Interface
/**
*Generic wrapper classes for widgets
* @constructor
*/
OpenAjax.widgets.WidgetWrapper = function() {};

with (OpenAjax.widgets.WidgetWrapper) {
	/**
	  * Sets the value of the specified property name to the value
	  * @param {String} propertyName This is the name of the property
	  * @param {Object} value The value of the property
	*/
	prototype.setPropertyValue = function(propertyName, value) {};

	/**
	  * Returns the current value of the requested property name.
	  * @param {String} propertyName This is the name of the property to retrieve
	  *
	*/
	prototype.getPropertyValue = function(propertyName) {};


}
Personal tools