{
super.renderHead(component, response);
response.render(JavaScriptHeaderItem.forReference(WicketWebSocketJQueryResourceReference.get()));
PackageTextTemplate webSocketSetupTemplate =
new PackageTextTemplate(WicketWebSocketJQueryResourceReference.class,
"res/js/wicket-websocket-setup.js.tmpl");
Map<String, Object> variables = Generics.newHashMap();
// set falsy JS values for the non-used parameter
if (Strings.isEmpty(resourceName))
{
int pageId = component.getPage().getPageId();
variables.put("pageId", pageId);
variables.put("resourceName", "");
}
else
{
variables.put("resourceName", resourceName);
variables.put("pageId", false);
}
Url baseUrl = component.getRequestCycle().getUrlRenderer().getBaseUrl();
CharSequence ajaxBaseUrl = Strings.escapeMarkup(baseUrl.toString());
variables.put("baseUrl", ajaxBaseUrl);
String contextPath = component.getRequest().getContextPath();
variables.put("contextPath", contextPath);
// preserve the application name for JSR356 based impl
variables.put("applicationName", component.getApplication().getName());
if (USING_JAVAX_WEB_SOCKET)
{
variables.put("filterPrefix", "");
}
else
{
variables.put("filterPrefix", component.getRequest().getFilterPath());
}
String webSocketSetupScript = webSocketSetupTemplate.asString(variables);
response.render(OnDomReadyHeaderItem.forScript(webSocketSetupScript));
}