}
@Override
public void encodeEnd(FacesContext ctx,
UIComponent component) throws IOException {
FormFiller formFiller = (FormFiller) component;
ResponseWriter writer = ctx.getResponseWriter();
writer.write("<script type=\"text/javascript\">");
if (formFiller.getMode() != null
&& formFiller.getMode().equals(FormFiller.MODE_FILL)) {
if (formFiller.getSubmitButtonId() != null) {
writer.write("$(function(){"
+ "$(\"#" + formFiller.getSubmitButtonId() + "\").attr(\"onclick\",\"submitForm();\");"
+ "});");
}
writer.write("function submitForm() {"
+ " var iframe = document.getElementById('" + formFiller.getIFrame().getId() + "');"
+ " var innerDoc = iframe.contentDocument || iframe.contentWindow.document;"
+ " $(innerDoc).find(\".btn\").click();"
+ "} "
+ "function submitParentForm() {"
+ " document.getElementById(\"" + FormBuilderInternalRenderer.getHtmlForm(component).getId() + Constants.sep + formFiller.getCallbackButton().getId() + "\").click();"
+ "}");
}
writer.write("$(function(){regIframe('" + formFiller.getIFrame().getId() + "');});"
+ "</script>");
}