private static void renderFormSubmitScriptIfNecessary(
FacesContext facesContext) throws IOException
{
final ExternalContext externalContext = facesContext
.getExternalContext();
final MyfacesConfig currentInstance = MyfacesConfig
.getCurrentInstance(externalContext);
ResponseWriter writer = facesContext.getResponseWriter();
if (currentInstance.isRenderFormSubmitScriptInline())
{
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
boolean autoScroll = currentInstance.isAutoScroll();
ScriptContext context = new ScriptContext(
currentInstance.isPrettyHtml());
context.prettyLine();
context.increaseIndent();
prepareScript(facesContext, context, autoScroll);