Receives JavaScript Object Notation (JSON)-encoded events in the browser that have been initiated on the server.
Note: This control is not portable to third-party servers. You can use it only in portlets published to instances of My webMethods Server.
The developer configures the topic to listen to, and writes any server code that posts events to that topic. When an event is received in the browser, the event body is posted over the browser's Open Ajax Hub. The developer can either subscribe to the Open Ajax Topic, or create a callback JavaScript function directly to respond to the event.
Internally, the Open Ajax control makes a hidden request to the server to fetch any available events. This request is handled using non-blocking IO techniques and does not incur the typical performance penalty of polling, and also provides more immediate response times.
The callback JavaScript function includes: function(eventName, eventBody) {}
. In this function, the eventName is the topic that the event was posted to, and the eventBody is the JSON representation of the posted event.
The following example demonstrates the Open Ajax control's callback function:
function (eventName, event) {
var eventText = 'A <em>' + eventName + '</em> event
was triggered by ' + event.user.fullName;
eventText += ' on the item ' + event.item.name;
alert(eventText);
}
To publish an event on the server, raise an object of type com.webmethods.event.impl.OpenAjaxEvent
, as in the following:
new OpenAjaxEvent("com.mycompany.myproduct.mytopic", myobj).raise();
The object's toString<
method should return a valid JSON string. Alternatively, you can repackage a subscribed CAF event.
The value
attribute specifies the Javascript to invoke when receiving an event posted to the OpenAjaxTopic. Default: function(eventName, eventBody) {}
Info | Value |
---|---|
Component Type | com.webmethods.caf.faces.events.OpenAjaxScript |
Handler Class | None |
Renderer Type | com.webmethods.caf.faces.events.OpenAjaxScript |
Description | Provides script access to any server side events on the Open Ajax Hub |
Palette Location | MWS Html/Control/Output/Open Ajax Script |
Name | Required | Type | Description |
---|---|---|---|
id | false | java.lang.String | Control identifier |
openAjaxTopic | true | javax.el.ValueExpression
(must evaluate to java.lang.String )
| The Open Ajax Topic that will be subscribed to (eg 'com.softwareag.events') |
rendered | false | javax.el.ValueExpression
(must evaluate to boolean )
|
True to render control; false to ignore it
If not specified, the default value is "true". |
shouldSubscribe | true | javax.el.ValueExpression
(must evaluate to java.lang.Boolean )
| If true, create a server-side subscription |
value | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Control value |
Output generated by Vdldoc View Declaration Language Documentation Generator.