protected UIGenerator createUIGenerator(HttpServletRequest request, XFormsSession session, String actionURL, String xslFile, String js) throws URISyntaxException, XFormsConfigException {
TransformerService transformerService = (TransformerService) getServletContext().getAttribute(TransformerService.class.getName());
URI uri = new File(getServletContext().getRealPath(xsltPath)).toURI().resolve(new URI(xslFile));
XSLTGenerator generator = new XSLTGenerator();
generator.setTransformerService(transformerService);
generator.setStylesheetURI(uri);
// todo: unify and extract parameter names
generator.setParameter("contextroot", request.getContextPath());
generator.setParameter("sessionKey", session.getKey());
if(session.getProperty(XFormsSession.KEEPALIVE_PULSE) != null){
generator.setParameter("keepalive-pulse",session.getProperty(XFormsSession.KEEPALIVE_PULSE));
}
generator.setParameter("action-url", actionURL);
generator.setParameter("debug-enabled", String.valueOf(LOGGER.isDebugEnabled()));
String selectorPrefix = Config.getInstance().getProperty(HttpRequestHandler.SELECTOR_PREFIX_PROPERTY,
HttpRequestHandler.SELECTOR_PREFIX_DEFAULT);
generator.setParameter("selector-prefix", selectorPrefix);
String removeUploadPrefix = Config.getInstance().getProperty(HttpRequestHandler.REMOVE_UPLOAD_PREFIX_PROPERTY,
HttpRequestHandler.REMOVE_UPLOAD_PREFIX_DEFAULT);
generator.setParameter("remove-upload-prefix", removeUploadPrefix);
String dataPrefix = Config.getInstance().getProperty("chiba.web.dataPrefix");
generator.setParameter("data-prefix", dataPrefix);
String triggerPrefix = Config.getInstance().getProperty("chiba.web.triggerPrefix");
generator.setParameter("trigger-prefix", triggerPrefix);
generator.setParameter("user-agent", request.getHeader("User-Agent"));
generator.setParameter("scripted", String.valueOf(js != null));
if (scriptPath != null) {
generator.setParameter("scriptPath", scriptPath);
}
if (cssPath != null) {
generator.setParameter("CSSPath", cssPath);
}
return generator;
}