Index: component/src/com/icesoft/faces/component/inputfile/InputFile.java =================================================================== --- component/src/com/icesoft/faces/component/inputfile/InputFile.java (revision 18798) +++ component/src/com/icesoft/faces/component/inputfile/InputFile.java (working copy) @@ -263,6 +263,42 @@ writer.write(divAsString); } + String submitOnUpload = getValidatedSubmitOnUpload(); + if (!submitOnUpload.equals(InputFile.SUBMIT_NONE)) { + boolean preUpload = + submitOnUpload.equals(InputFile.SUBMIT_PRE_UPLOAD) || + submitOnUpload.equals(InputFile.SUBMIT_PRE_POST_UPLOAD); + boolean postUpload = + submitOnUpload.equals(InputFile.SUBMIT_POST_UPLOAD) || + submitOnUpload.equals(InputFile.SUBMIT_PRE_POST_UPLOAD); + + UIComponent ownerForm = DomBasicRenderer.findForm(this); + String ownerFormClientId = (ownerForm != null) ? ownerForm.getClientId(context) : null; + if(ownerFormClientId != null) + { + String id = this.getClientId(context); + writer.write(""); + } + } + writer.write(""); writer.write(""); } Index: component/src/com/icesoft/faces/component/inputfile/InputFileRenderer.java =================================================================== --- component/src/com/icesoft/faces/component/inputfile/InputFileRenderer.java (revision 18798) +++ component/src/com/icesoft/faces/component/inputfile/InputFileRenderer.java (working copy) @@ -93,44 +93,6 @@ writer.writeAttribute("allowtransparency", "true", null); writer.endElement("iframe"); - String submitOnUpload = c.getValidatedSubmitOnUpload(); - if (!submitOnUpload.equals(InputFile.SUBMIT_NONE)) { - boolean preUpload = - submitOnUpload.equals(InputFile.SUBMIT_PRE_UPLOAD) || - submitOnUpload.equals(InputFile.SUBMIT_PRE_POST_UPLOAD); - boolean postUpload = - submitOnUpload.equals(InputFile.SUBMIT_POST_UPLOAD) || - submitOnUpload.equals(InputFile.SUBMIT_PRE_POST_UPLOAD); - - writer.startElement("script", c); - writer.writeAttribute("type", "text/javascript", null); - writer.writeAttribute("id", id, null); - writer.writeText( - "var register = function() {" + - "var frameElem = document.getElementById('" + frameName + "');" + - "if(!frameElem) { return; }" + - "var frame = frameElem.contentWindow;" + - "var submit = function() { " + - "if(arguments.length == 1 && arguments[0] == 1) { " + - ( postUpload - ? ("Ice.InputFileIdPostUpload = '" + id + "'; Ice.InputFileIdPreUpload = null;") - : "return;" ) + - " } " + - "else { " + - ( preUpload - ? ("Ice.InputFileIdPreUpload = '" + id + "'; Ice.InputFileIdPostUpload = null;") - : "return;" ) + - " } try { if(document.getElementById('"+id+"')) { '" + id + "'.asExtendedElement().form().submit(); } } catch (e) { logger.warn('Form not available', e); } finally { Ice.InputFileIdPreUpload = null; Ice.InputFileIdPostUpload = null; } };" + - //trigger form submit when the upload starts - "frame.document.getElementsByTagName('form')[0].onsubmit = submit;" + - //trigger form submit when the upload ends and re-register handlers - "var uploadEnd = function() { submit(1); setTimeout(register, 200); };" + - "if (frame.attachEvent) { frame.attachEvent('onunload', uploadEnd); } else { frame.onunload = uploadEnd; } };" + - //register the callback after a delay because IE6 or IE7 won't make the iframe available fast enough - "setTimeout(register, 300);", null); - writer.endElement("script"); - } - FileInfo fileInfo = c.getFileInfo(); if (log.isDebugEnabled()) log.debug("InputFileRenderer fileInfo: " + fileInfo);