Version 0.8.1.570
Copyright 2007-2008, Demoxi, Inc.
To get a quick start with Demoxi widgets, see the Demoxi Widgets Developer's Guide. It shows how to install the widget SDK and provides a detailed discussion of a fully functional Hello, World example widget.
Demoxi widget services use the Representational State Transfer (REST)
API style
(see http://en.wikipedia.org/wiki/Representational_State_Transfer).
All server requests are requested presented to http://localhost:4073. These
are typically GET requests
(although either GET or POST will work).
The
URL should be of the form:
http://localhost:4073/Widget/[Command]/[Widget]?parameter1=value1¶meter2=value2 ....
Command is the name of a widget service like Open; Widget is a widget identifier
(either a widget handle or the widget bundle name without the DW ending); and
parameter is a request parameter like skin.
For example, to open a widget the Hello, World widget, use http://localhost:4073/Widget/Open/Hello. And to close the Hello, World widget, use http://localhost:4073/Widget/Close/<TMPL_VAR handle>. For a description of the state variables that are served with each widget file, see State Variables.
Typical return status codes include the following:
| Status Code | Description |
| 200 OK | Request processed successfully. |
| 400 Bad Request | The request could not be understood by the server due to malformed syntax. |
| 401 Unauthorized | The request requires user authentication. |
| 500 Internal Server Error | The server encountered an unexpected condition which prevented it from fulfilling the request. |
Return status codes do not cover all possible HTTP status codes that could be
returned, but only those returned from the server. For example, if the request
cannot reach the server, you will likely get a 503 Service Unavailable response.
So, do not write your code just to handle just the documented response codes.
JSON is used to return data from functions. JSON (JavaScript Object Notation) is a lightweight data format based on the object notation of the JavaScript language. It does not require JavaScript to read or write; it is easy to parse by any language; and libraries and tools exist in many languages to handle JSON. For a complete description of JSON and its many uses, we suggest Douglas Crockford's JSON.org (http://json.org) and JSON: The Fat-Free Alternative to XML (http://json.org/xml.html).
A typical JSON return data structure might look like this:
jsonResult = '{ "personal" : { "language" : "eng" } }';
Accessing this JSON data structure from JavaScript is easy:
result = eval ("(" + jsonResult + ")"); alert (result.personal.language);
The jQuery getJSON function calls eval for you so you can access the data
directly:
$.getJSON ( "http://localhost:4073/Widget/GetVaultAttribute/<TMPL_VAR handle>" ,{name: "personal.language"} ,function (result) { alert (result.personal.language); } );
Widgets use a template mechanism to inject state variables into widget files.
To access these variables within your widget HTML or JavaScript files, use the
<TMPL_VAR> prefix.
For example, to access the name of the current user via userName
from an HTML widget file:
<html>
<body>
Welcome <TMPL_VAR userName>!
</body>
</html>
The following state variables are available to all widgets:
| State Variable | Description |
| apiServer | The demoxi.net webserver URL. |
| handle | The widget handle. |
| serverAuth | The demoxi.net server authorization handle for the currently signed-in user. |
| userName | The currently signed-in user. |
The widget commands allow the manipulation of widget appearance programmatically. It should be noted that since a widget's appearance is largely defined by its skin(s), making significant alterations to the appearance (e.g. changing a widget's color) is handled by resetting its skin. As such, most of the remaining commands have to do with size and visibility.
Closes the specified widget.
http://localhost:4073/Widget/Close/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
See also State Variables and Request Format.
Puts the widget into drag mode, locking its motion to the mouse until the mouse button is released.
http://localhost:4073/Widget/BeginDrag/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
See also State Variables and Request Format.
Ends dragging that was begun with BeginDrag.
http://localhost:4073/Widget/EndDrag/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
See also State Variables and Request Format.
Repositions a widget.
http://localhost:4073/Widget/Move/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| x | Yes | The x coordinate for the upper left corner of the widget. If unsigned, this coordinate is absolute. If signed (+ or -), it is relative to the previous coordinate. |
| y | Yes | The y coordinate for the upper left corner of the widget. If unsigned, this coordinate is absolute. If signed (+ or -), it is relative to the previous coordinate. |
As an example, assume a Hello, World widget whose current upper left coordinate is (200, 200).
Move(Hello, 300, 400) (or more properly, http://localhost:4073/Widget/Move/Hello/[handle]?x=300&y=400)
would move the Hello, World widget to the absolute screen coordinates of (300,400). On the other hand, Move(300, +50)
would move the widget to (300, 250). A positional arguments of 0 (zero) will always be interpreted as an offset
to the current coordinate; Move(300, 0) would result in a widget at (300, 200).
See also State Variables and Request Format.
Opens the specified widget.
http://localhost:4073/Widget/Open/[widget bundle]
| Parameter | Required | Description |
| widget bundle | Yes | The name of a widget bundle without the .dw ending. |
| skin | No | The skin, if specified, must be present in the widget's manifest. If it is not, or if the argument is omitted, then the default skin listed in the widget manifest will be used to render the widget. |
See also State Variables and Request Format.
Gets widget properties.
http://localhost:4073/Widget/GetProperties/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| names | Yes | The property names. |
| section | No | A section within the properties area. |
See also State Variables and Request Format.
http://localhost:4073/Widget/GetProperties/12345678?section=defaults&property1&property2
| Parameter | Description |
| values | The property values. |
If there is no existing value or name does not exist, then null will be returned.
See also Response Status Codes and Response Data.
{ "property1" : "true", "property2" : "shazzam" }
Sets widget properties.
http://localhost:4073/Widget/SetProperties/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| name/value pairs | Yes | The property names and values. |
| section | No | A section within the properties area. |
See also State Variables and Request Format.
http://localhost:4073/Widget/SetProperties/12345678?section=defaults&property1=true&property2=shazzam
Changes the height and width of a widget. (coming soon)
Switches the widget to a different skin, or with a variable-sized skin, resizes
the current skin. This command may be invoked with either a skin argument,
or width and height arguments. With a skin argument, the skin (i.e., mask)
of the widget is replaced, and the window is changed to the new shape. With width
and height arguments, the widget shape is transformed according to the description
in the widget manifest, and the window is changed to the new shape.
Note that the content of the widget is unchanged, so it is up to you to make the widget look correct in its new skin.
Widgets also may have multiple skins, each describing a different size (e.g. small, medium, and large). If you want to resize the widget to one of these predefined sizes, you should use the SetSkin command instead.
Finally, note that a skin can have an arbitrary shape, as defined by its skin's mask. This command alters the height and width of the widget, so changing the width of a circular widget would result in an ellipse.
http://localhost:4073/Widget/Resize/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| skin | No | The new skin, if specified, must be present in the widget's manifest. |
| width | No | The new widget width. |
| height | No | The new widget height. |
See also State Variables and Request Format.
Shows or hides the widget.
http://localhost:4073/Widget/Show/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| show | Yes | 1 to show the widget; 0 to hide it. |
See also State Variables and Request Format.
Changes the widget skin. (coming soon)
http://localhost:4073/Widget/SetSkin/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| skin | No | The new skin, if specified, must be present in the widget's manifest. |
See also State Variables and Request Format.
Plays a sound file stored in the widget bundle.
http://localhost:4073/Widget/PlaySound/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| sound | Yes | The name of the sound file stored in the widget bundle. |
Currently the only supported sound file format is WAV. Support for additional formats may be added in the future.
See also State Variables and Request Format.
Sets the window title for the widget.
All widgets should have a title, even if it is not displayed in the widget window. This allows the title to be shown in other useful places; for example, the title would be shown when a Windows user is Alt-Tabbing through a series of windows.
http://localhost:4073/Widget/SetTitle/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| title | No | A short string defining the title of the widget. |
The length of title is limited to 255 characters, but having so long a title
is highly inadvisable from a UI point of view; short strings are the most appropriate.
UTF-8 is supported, so titles in non-Roman character sets are OK.
See also State Variables and Request Format.
Gets the Demoxi platform version.
http://localhost:4073/Widget/GetVersion/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
See also State Variables and Request Format.
http://localhost:4073/Widget/GetVersion/12345678
| Parameter | Description |
| major | Major version number. |
| minor | Minor version number. |
| revision | Revision number. |
| build | Build number. |
See also Response Status Codes and Response Data.
{ "major" : 0, "minor" : 8, "revision" : 1, "build" : 555, }
The identity commands allow the access to the user's identity information.
Returns the value of public attributes in the user's identity vault.
http://localhost:4073/Widget/GetVaultAttributes/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| vault | No | The specific vault within the set user's identity vaults. Defaults to wallet. |
| names | Yes | The attribute names in category.name format. |
See also State Variables and Request Format.
http://localhost:4073/Widget/GetVaultAttributes/12345678?personal.yob&personal.language&personal.
gender&address.co&address.postcode
| Field | Description |
| values | The attribute values. |
| Error Code | Description |
| 401 Unauthorized | The request requires user authentication. |
| 403 Forbidden | The user has refused access to the attribute. |
If there is no existing value or name does not exist, then null will be returned.
If a requested value is not public, then the call will fail. Error code 401 means you should wait
and retry as the user may be asked to confirm that your widget should be allowed to access the
attribute. Error code 403 means the user has refused access to the attribute.
See also Response Status Codes and Response Data.
{ "personal" : { "yob" : "1963", "language" : "English", "gender" : "M" }, "address" : { "co" : "United States", "postcode" : "98004" } }
Sets the value of public attributes in the user's identity vault.
http://localhost:4073/Widget/SetVaultAttributes/[widget handle]
| Parameter | Required | Description |
| widget handle | Yes | The widget handle. |
| vault | No | The specific vault within the set user's identity vaults. Defaults to wallet. |
| name/value pairs | Yes | The attribute names and values. |
See also State Variables and Request Format.
http://localhost:4073/Widget/SetVaultAttributes/12345678?personal.language=French&personal.yob=1992&address.
co=
United States&personal.gender=M&address.postcode=98001
| Error Code | Description |
| 401 Unauthorized | The request requires user authentication. |
| 403 Forbidden | The user has refused access to the attribute. |
If a requested value is not public, then the call will fail. Error code 401 means you should wait
and retry as the user may be asked to confirm that your widget should be allowed to access the
attribute. Error code 403 means the user has refused access to the attribute.
See also Response Status Codes.