}
}
private final static class AjaxSubmitFunctionResourceRenderer extends Renderer implements UserResourceRenderer2 {
public void encodeToHead(FacesContext facesContext, UIComponent component) throws IOException {
JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(component, facesContext);
Map<String, Object> options = AjaxRendererUtils.buildEventOptions(facesContext, component, true);
options.put("requestDelay", new JSReference("options.requestDelay"));
options.put("similarityGroupingId",
new JSReference("options.similarityGroupingId || '" + component.getClientId(facesContext)
+ "'"));
options.put("data", new JSReference("data"));
options.put("requestTime", new JSReference("options.requestTime"));
options.put("timeout", new JSReference("options.timeout"));
options.put("eventsQueue", new JSReference("options.eventsQueue"));
options.put("implicitEventsQueue", new JSReference("options.implicitEventsQueue"));
options.put("ignoreDupResponses", new JSReference("options.ignoreDupResponses"));
ajaxFunction.addParameter(options);
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HTML.SCRIPT_ELEM, component);
responseWriter.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
responseWriter.writeText("var " + AJAX_SUBMIT + " = function(data, options) {" + ajaxFunction.toScript()
+ "};", null);
responseWriter.endElement(HTML.SCRIPT_ELEM);
}