*/
public static void writeCodeBeforeBodyEnd(FacesContext facesContext) throws IOException
{
ResponseWriter writer = facesContext.getResponseWriter();
MyfacesConfig myfacesConfig = MyfacesConfig.getCurrentInstance(facesContext.getExternalContext());
if (myfacesConfig.isDetectJavascript())
{
if (! JavascriptUtils.isJavascriptDetected(facesContext.getExternalContext()))
{
writer.startElement("script",null);
writer.writeAttribute("attr", HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
StringBuffer script = new StringBuffer();
script.append("document.location.replace('").
append(facesContext.getApplication().getViewHandler().getResourceURL(facesContext, "/_javascriptDetector_")).append("?goto=").append(facesContext.getApplication().getViewHandler().getActionURL(facesContext, facesContext.getViewRoot().getViewId())).append("');");
writer.writeText(script.toString(),null);
writer.endElement(HTML.SCRIPT_ELEM);
}
}
if (myfacesConfig.isAutoScroll())
{
HtmlRendererUtils.renderAutoScrollFunction(facesContext, writer);
}
// now write out listeners