rendered paste body<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Mule Notifications Example</title>
<link rel="stylesheet" href="notifications.css"/>
<!-- stripped down version of dojo that just includes the peices necessary for cometd -->
<script type="text/javascript" src="mule-resource/js/dojo/dojo.js"></script>
<script type="text/javascript" src="mule-resource/js/mule.js"></script>
<script type="text/javascript">
function init()
{
mule.subscribe("/mule/notifications", notif);
}
function dispose()
{
mule.unsubscribe("/mule/notifications", notif);
}
function notif(message)
{
console.debug("data:" + message.data);
if (!message.data)
{
console.debug("bad message format " + message);
return;
}
var event = dojo.fromJson(message.data);
var table = document.getElementById('notificationTable');
var newRow = table.insertRow(1);
newRow.className = event.type;
newRow.insertCell(0).innerHTML = event.action;
newRow.insertCell(1).innerHTML = event.type;
newRow.insertCell(2).innerHTML = event.actionName;
newRow.insertCell(3).innerHTML = event.source;
newRow.insertCell(4).innerHTML = event.resourceIdentifier;
newRow.insertCell(5).innerHTML = event.serverId;
newRow.insertCell(6).innerHTML = event.timestamp;
table.scrollTop = table.scrollHeight - table.clientHeight
}
function rpcEcho() {
var data = new Object();
data.phrase = document.getElementById('phrase').value;
data.user = document.getElementById('user').value;
mule.rpc("/services/echo", data, rpcEchoResponse);
}
function rpcEchoResponse(message) {
document.getElementById("response").innerHTML = "<b>Response: </b>" + message.data + "\n";
}
</script>
</head>
<body onload="init()" onunload="dispose()">
<h1>Mule Notifications</h1>
<div>
Secure Echo: <input id="phrase" type="text"/>
<select id="user">
<option value="anonymous">Anonymous</option>
<option value="administrator" selected="true">Administrator</option>
</select>
<input id="sendButton" class="button" type="submit" name="Go" value="Send" onclick="rpcEcho();"/>
</div>
<pre id="response"></pre>
<p/>
<div style="position:relative;width:800px;height:300px;overflow:auto;">
<table id="notificationTable">
<thead>
<tr>
<th width="5%">ID</th>
<th width="5%">Type</th>
<th width="10%">Action</th>
<th width="35%">Source</th>
<th width="25%">Resource ID</th>
<th width="10%">Server ID</th>
<th width="10%">Time</th>
</tr>
</thead>
</table>
</div>
</body>
</html>