AddResource addResource = AddResourceFactory.getInstance(context);
if (!context.getExternalContext().getRequestMap()
.containsKey(XFormRenderer.class.getName() + "_SCRIPTS")) {
addResource.addJavaScriptAtPosition
(context, AddResource.HEADER_BEGIN,
new MyFacesResourceHandler(XFormRenderer.class, "helpers.js"));
addResource.addJavaScriptAtPosition
(context, AddResource.HEADER_BEGIN,
new MyFacesResourceHandler
(XFormRenderer.class, "xforms2html.js"));
context.getExternalContext().getRequestMap()
.put(XFormRenderer.class.getName() + "_SCRIPTS", Boolean.TRUE);
}
// Add styles
addResource.addStyleSheet
(context, AddResource.HEADER_BEGIN,
new MyFacesResourceHandler(XFormRenderer.class, "xforms.css"));
// Write individual JS
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute
(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
String jsPrefix = JavascriptUtils
.getValidJavascriptName(comp.getClientId(context),false);
writer.write("window." + jsPrefix + "baseData={\n");
writer.write("jsPrefix: \"" + jsPrefix + "\",\n");
writer.write("elementIdPrefix: \""
+ comp.getClientId(context)
+ NamingContainer.SEPARATOR_CHAR + "\",\n");
String urlPrefix = addResource.getResourceUri
(context, new MyFacesResourceHandler(JSLoading.class, ""));
writer.write("resourcePrefix: \"" + urlPrefix + "\",\n");
writer.write("dataPrefix: \"" + DATA_PREFIX + "\",\n");
writer.write("triggerPrefix: \"" + TRIGGER_PREFIX + "\",\n");
writer.write("removeUploadPrefix: \"" + REMOVE_UPLOAD_PREFIX + "\",\n");
Locale locale = context.getViewRoot().getLocale();