This should be easy, but I'm striking out...

I want to use a new Javascript feature
(EventSource<http://dev.w3.org/html5/eventsource/>,
part of HTML5 WebSockets) to push notifications from the server to the
browser. Getting the basic mechanism to work was easy. What I can't figure
out how to do is once I get the notification on the client, how to tell
Wicket to update the relevant components via Ajax. In other words, the
equivalent of AjaxRequestTarget.addComponent(Component) in Javascript.

This is how far I got, which didn't work. I was trying to use wicketAjaxGet:

Script at the top of my page:

var wary = new Array();
var source = new EventSource("events");
source.onmessage = function(event) {
for (var i = 0, item; item = wary[i]; i++) {
 wicketAjaxGet("'"+item+"'",
function(){}.bind(this),function(){}.bind(this));
 }
};

Method in my Component subclass:

public void renderHead(IHeaderResponse response)
{
 String js = "wary.push('" + b.getCallbackUrl() + "')";
 response.renderOnLoadJavascript(js);
}

Any help is appreciated.

Julian

Reply via email to