Class Index | File Index

Classes


Class Ozone.eventing.Widget


Defined in: Widget.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Ozone.eventing.Widget(widgetRelay, afterInit)
The Ozone.eventing.Widget object manages the eventing for an individual widget (Deprecated).
Field Summary
Field Attributes Field Name and Description
<static>  
Ozone.eventing.Widget.widgetRelayURL
The location of the widget relay file.
Method Summary
Method Attributes Method Name and Description
<static>  
Ozone.eventing.Widget.getInstance(afterInit, widgetRelay)
Retrieves Ozone.eventing.Widget Singleton instance
 
Returns the Widget Id
 
publish(channelName, message, dest)
Publish a message to a given channel
 
subscribe(channelName, handler)
Subscribe to a named channel for a given function.
 
unsubscribe(channelName)
Unsubscribe to a named channel
Class Detail
Ozone.eventing.Widget(widgetRelay, afterInit)
The Ozone.eventing.Widget object manages the eventing for an individual widget (Deprecated). This constructor is deprecated. You should use Ozone.eventing.Widget.getInstance
this.widgetEventingController = new Ozone.eventing.Widget(
'owf-sample-html/js/eventing/rpc_relay.uncompressed.html', function() {

 //put code here to execute after widget init - perhaps immediately publish to a channel

});
Parameters:
{String} widgetRelay
The URL for the widget relay file. The relay file must be specified with full location details, but without a fully qualified path. In the case where the relay is residing @ http://server/path/relay.html, the path used must be from the context root of the local widget. In this case, it would be /path/relay.html. Do not include the protocol.
{Function} afterInit
- callback to be executed after the widget is finished initializing.
Deprecated:
Since OWF 3.7.0 You should use Ozone.eventing.Widget.getInstance
Throws:
{Error}
throws an error with a message if widget initialization fails
Field Detail
<static> Ozone.eventing.Widget.widgetRelayURL
The location of the widget relay file. The relay file should be defined globally for the entire widget by setting Ozone.eventing.Widget.widgetRelayURL to the relay file url, immediately after including the widget bundle javascript. If the relay is not defined at all it is assumed to be at /[context]/js/eventing/rpc_relay.uncompressed.html. The relay file must be specified with full location details, but without a fully qualified path. In the case where the relay is residing @ http://server/path/relay.html, the path used must be from the context root of the local widget. In this case, it would be /path/relay.html. Do not include the protocol.
<script type="text/javascript" src="../../js-min/owf-widget-min.js"></script>
<script>
      //The location is assumed to be at /[context]/js/eventing/rpc_relay.uncompressed.html if it is not
      //set the path correctly below
      Ozone.eventing.Widget.widgetRelayURL = '/owf/js/eventing/rpc_relay.uncompressed.html';
      //...
</script>
Since:
OWF 3.7.0
Method Detail
<static> Ozone.eventing.Widget.getInstance(afterInit, widgetRelay)
Retrieves Ozone.eventing.Widget Singleton instance
<script type="text/javascript" src="../../js-min/owf-widget-min.js"></script>
<script>
      //The location is assumed to be at /[context]/js/eventing/rpc_relay.uncompressed.html if it is not
      //set the path correctly below
      Ozone.eventing.Widget.widgetRelayURL = '/owf/js/eventing/rpc_relay.uncompressed.html';

      owfdojo.addOnLoad(function() {
        //get widget instance
        var widgetEventingController = Ozone.eventing.Widget.getInstance();
        //do something
        widgetEventingController.publish("FooChannel", 'message goes here');
      });
</script>
Parameters:
{Function} afterInit Optional
callback function to be executed after the Ozone.eventing.Widget singleton is initialized
{String} widgetRelay Optional
Optionally redefine the location of the relay file. The relay file should be defined globally for the entire widget by setting Ozone.eventing.Widget.widgetRelayURL to the relay file url, immediately after including the widget bundle javascript. If the relay is not defined at all it is assumed to be at /[context]/js/eventing/rpc_relay.uncompressed.html. The relay file must be specified with full location details, but without a fully qualified path. In the case where the relay is residing @ http://server/path/relay.html, the path used must be from the context root of the local widget. In this case, it would be /path/relay.html. Do not include the protocol.
Since:
OWF 3.7.0
Throws:
{Error}
throws an error with a message if widget initialization fails

{String} getWidgetId()
Returns the Widget Id
//decode and retrieve the widget's unique id
var complexIdString = this.eventingController.getWidgetId();
var complexIdObj = owfdojo.toJson(complexIdString);

//complexIdObj will look like
// {
//  //widget's uniqueId
//  id:"49cd21f0-3110-8121-d905-18ffa81b442e"
// }

//get Widget's uniqueId
alert('widget id = ' + complexIdObj.id);
Returns:
{String} The widgetId is a complex JSON encoded string which identifies a widget for Eventing. Embedded in this string is the widget's uniqueId as the 'id' attribute. There is other data is in the string which is needed for Eventing and other APIs to function properly. This complex widgetId string may be used in the Ozone.eventing.Widget.publish function to designate a specific recipient for a message. Additionally, once subscribed to a channel via Ozone.eventing.Widget.subscribe during the receipt of a message, the sender's widgetId is made available as the first argument to the handler function.

publish(channelName, message, dest)
Publish a message to a given channel
this.widgetEventingController = Ozone.eventing.Widget.getInstance();
this.widgetEventingController.publish("ClockChannel", currentTimeString);
Parameters:
{String} channelName
The name of the channel to publish to
{Object} message
The message to publish to the channel.
{String} dest Optional
The id of a particular destination. Defaults to null which sends to all subscribers on the channel. See Ozone.eventing.Widget.getWidgetId for a description of the id.

subscribe(channelName, handler)
Subscribe to a named channel for a given function.
this.widgetEventingController = Ozone.eventing.Widget.getInstance();
this.widgetEventingController.subscribe("ClockChannel", this.update);

var update = function(sender, msg, channel) {
    document.getElementById('currentTime').innerHTML = msg;
}
Parameters:
{String} channelName
The channel to subscribe to.
{Function} handler
The function you wish to subscribe. This function will be called with three arguments: sender, msg, channel.
{String} handler.sender Optional
The first argument passed to the handler function is the id of the sender of the message. See Ozone.eventing.Widget.getWidgetId for a description of this id.
{Object} handler.msg Optional
The second argument passed to the handler function is the message itself.
{String} handler.channel Optional
The third argument passed to the handler function is the channel the message was published on.

unsubscribe(channelName)
Unsubscribe to a named channel
this.widgetEventingController.unsubscribe("ClockChannel");
Parameters:
{String} channelName
The channel to unsubscribe to.

Documentation generated by JsDoc Toolkit 2.3.2 on Fri Oct 05 2012 16:51:05 GMT-0400 (EDT)