Skip to content

Pushing javascript to the client

uklance edited this page Jul 12, 2012 · 15 revisions

Custom javascript can be pushed to the client when an event is received using the AjaxResponseRenderer

@Inject
private AjaxResponseRenderer ajaxResponseRenderer;

onPushEvent(final String message) {
    ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
        public void run(JavaScriptSupport jss) {
            jss.addScript("alert('%s')", message);
        }
    });
}
Clone this wiki locally