use of org.apache.wicket.util.template.PackageTextTemplate in project wicket-dashboard by decebals.
the class DashboardColumnPanel method renderHead.
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
CharSequence script = sortableAjaxBehavior.getCallbackFunctionBody();
Map<String, String> vars = new HashMap<String, String>();
vars.put("component", get("columnContainer").getMarkupId());
vars.put("stopBehavior", script.toString());
PackageTextTemplate template = new PackageTextTemplate(DashboardColumnPanel.class, "res/sort-behavior.template.js");
template.interpolate(vars);
response.render(OnDomReadyHeaderItem.forScript(template.getString()));
}
use of org.apache.wicket.util.template.PackageTextTemplate in project wicket by apache.
the class BaseWebSocketBehavior method renderHead.
@Override
public void renderHead(Component component, IHeaderResponse response) {
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);
}
WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(component.getApplication());
CharSequence baseUrl = getBaseUrl(webSocketSettings);
Args.notNull(baseUrl, "baseUrl");
variables.put("baseUrl", baseUrl);
Integer port = getPort(webSocketSettings);
variables.put("port", port);
Integer securePort = getSecurePort(webSocketSettings);
variables.put("securePort", securePort);
CharSequence contextPath = getContextPath(webSocketSettings);
Args.notNull(contextPath, "contextPath");
variables.put("contextPath", contextPath);
// preserve the application name for JSR356 based impl
variables.put("applicationName", component.getApplication().getName());
CharSequence filterPrefix = getFilterPrefix(webSocketSettings);
Args.notNull(filterPrefix, "filterPrefix");
variables.put("filterPrefix", filterPrefix);
final CharSequence sessionId = getSessionId(component);
variables.put("sessionId", sessionId);
String webSocketSetupScript = webSocketSetupTemplate.asString(variables);
response.render(OnDomReadyHeaderItem.forScript(webSocketSetupScript));
}
Aggregations