#API Object: OWF.Preferences.getWidget(cfg)#
#####Definition:
Use the /getWidget API to return a Widget based on its widget ID.
#####How it works:##### A system makes a call to OWF asking if a widget exists. To make this call, one of the following REST Calls will request a widget ID.
#####Request URL:#####
https://localhost:8443/owf/prefs/widget/WIDGETID
#####Request Method:##### GET, Form_Method:none
#####Requirements:##### widgetID
Optional: none
#####Response:##### OWF returns the matching widgetID, as shown below. However, if the widgetID is an empty string (""), OWF will return a list of all widgets.
{
"id": 39,
"namespace": "widget",
"value": {
"originalName": "Channel Shouter",
"universalName": null,
"editable": true,
"disabled": false,
"visible": true,
"favorite": false,
"groupWidget": false,
"position": 10,
"userId": "testAdmin1",
"userRealName": "Test Admin 1",
"namespace": "Channel Shouter",
"description": null,
"url": "examples/walkthrough/widgets/ChannelShouter.gsp",
"headerIcon": "themes/common/images/widget-icons/ChannelShouter.png",
"image": "themes/common/images/widget-icons/ChannelShouter.png",
"smallIconUrl": "themes/common/images/widget-icons/ChannelShouter.png",
"largeIconUrl": "themes/common/images/widget-icons/ChannelShouter.png",
"width": 295,
"height": 250,
"x": 0,
"y": 0,
"minimized": false,
"maximized": false,
"widgetVersion": "1.0",
"groups": [
],
"tags": [
],
"definitionVisible": true,
"singleton": false,
"background": false,
"descriptorUrl": null,
"allRequired": [
],
"directRequired": [
],
"intents": {
"send": [
],
"receive": [
]
},
"widgetTypes": [
{
"id": 1,
"name": "standard",
"displayName": "standard"
}
]
},
"path": "eb5435cf-4021-4f2a-ba69-dde451d12551"
}
#####How to use it:##### Use it to find specific information about a widget including its Descriptor URL (if it has one) and its universal name.
###Example###
The following is an example of a call to get a widget ID:
var onSuccess = function(obj) {
if (obj.value) {
alert(obj.value.namespace);
}
};
var onFailure = function(error) {
alert(error);
};
OWF.Preferences.getWidget({
widgetId:'eb5435cf-4021-4f2a-ba69-dde451d12551',
onSuccess:onSuccess,
onFailure:onFailure
});
###Resource Information###
| Parameter | Description |
| {Object} cfg | Use the following properties to configure the object. |
| {String} cfg.namespace | The namespace of the user preference. |
| {String} cfg.name | The name of the user preference. |
| {Function} cfg.onSuccess | The function that will be called if the user preference is successfully deleted from the database. |
| {Function} cfg.onFailure Optional | The system returns this function if the user preference cannot be deleted from the database or if the preference does not exist. If this function is not specified a default error message display. This function passes back the following parameters: error: String Status: The HTTP Status code |
###Possible Errors###
| Error | Action |
| This will happen when getWidget is called using a widgetId that doesn't exist. HTTP Status 404: “...Widget with guid of undefined not found.” | Make sure widgetId is set to a non-null string. |