Author: nbelaevski
Date: 2008-08-31 15:00:35 -0400 (Sun, 31 Aug 2008)
New Revision: 10251
Modified:
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
Log:
https://jira.jboss.org/jira/browse/RF-4334
https://jira.jboss.org/jira/browse/RF-4193
Modified:
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
---
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-08-31
18:48:37 UTC (rev 10250)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-08-31
19:00:35 UTC (rev 10251)
@@ -151,7 +151,8 @@
if (this.uploadObject.isFlash) {
this.uploadObject._flashSubmitForm(this);
} else {
- this.uploadObject.submitForm(this);
+ this.uploadObject.createFrame();
+ setTimeout(function(){this.uploadObject.submitForm(this)}.bind(this), 0);
}
},
@@ -994,14 +995,6 @@
return parentForm;
},
- _getAction: function(f) {
- return f.getAttributeNode('action').nodeValue;
- },
-
- _setAction: function(f, newValue) {
- f.getAttributeNode('action').nodeValue = newValue;
- },
-
submitForm: function(entry) {
var parentForm = this.getForm();
@@ -1010,20 +1003,23 @@
}
var formUpload = !(entry && entry instanceof FileUploadEntry);
- var oldTarget = parentForm.target;
- var oldEnctype = parentForm.enctype;
- var oldEncoding = parentForm.encoding;
- var oldAction = this._getAction(parentForm);
+ var oldTarget = Richfaces.readAttribute(parentForm, "target");
+ var oldEnctype = Richfaces.readAttribute(parentForm, "enctype");
+ var oldEncoding = Richfaces.readAttribute(parentForm, "encoding");
+ var oldAction = Richfaces.readAttribute(parentForm, "action");
try {
if (!formUpload) {
entry.uid = Math.random().toString();
- parentForm.encoding = "multipart/form-data";
- parentForm.enctype = "multipart/form-data";
- this._setAction(parentForm, this.actionUrl + (/\?/.test(this.actionUrl) ?
'&_richfaces_upload_uid' : '?_richfaces_upload_uid') + '=' +
encodeURI(entry.uid) + "&id=" + this.id +
"&_richfaces_upload_file_indicator=true"+"&AJAXREQUEST="+this.progressBar.containerId);
- parentForm.target = this.id + "_iframe";
+ Richfaces.writeAttribute(parentForm, "encoding",
"multipart/form-data");
+ Richfaces.writeAttribute(parentForm, "enctype",
"multipart/form-data");
+ Richfaces.writeAttribute(parentForm, "action",
+ this.actionUrl + (/\?/.test(this.actionUrl) ? '&_richfaces_upload_uid'
: '?_richfaces_upload_uid') + '=' + encodeURI(entry.uid) +
"&id=" + this.id +
"&_richfaces_upload_file_indicator=true"+"&AJAXREQUEST="+this.progressBar.containerId);
+
+ Richfaces.writeAttribute(parentForm, "target", this.id +
"_iframe");
+
var inputs = parentForm.elements;
var entryInput = entry.fileInput;
@@ -1070,13 +1066,13 @@
this._enableEntries(true);
}
} finally {
- parentForm.action = oldAction;
- parentForm.encoding = oldEncoding;
- parentForm.enctype = oldEnctype;
+ Richfaces.writeAttribute(parentForm, "action", oldAction);
+ Richfaces.writeAttribute(parentForm, "encoding", oldEncoding);
+ Richfaces.writeAttribute(parentForm, "enctype", oldEnctype);
if (formUpload) {
this.currentInput.disabled = true;
}else {
- parentForm.target = oldTarget;
+ Richfaces.writeAttribute(parentForm, "target", oldTarget);
this.getFileSizeScript(entry.uid, this.formId)
}
}
@@ -1095,8 +1091,11 @@
if (!f) {
throw "No parent form found!";
}
- f.encoding = f.enctype = "multipart/form-data";
- f.action = this.actionUrl + (/\?/.test(this.actionUrl) ?
'&_richfaces_upload_uid' : '?_richfaces_upload_uid') +
'=_richfaces_form_upload' + "&id=" + this.id +
"&_richfaces_upload_file_indicator=true";
+ Richfaces.writeAttribute(f, "encoding", "multipart/form-data");
+ Richfaces.writeAttribute(f, "enctype", "multipart/form-data");
+ Richfaces.writeAttribute(f, "action",
+ this.actionUrl + (/\?/.test(this.actionUrl) ? '&_richfaces_upload_uid' :
'?_richfaces_upload_uid') + '=_richfaces_form_upload' +
"&id=" + this.id + "&_richfaces_upload_file_indicator=true");
+
this.currentInput.disabled = true;
this._enableEntries(false);
return true;
Modified: trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
--- trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-08-31
18:48:37 UTC (rev 10250)
+++ trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-08-31
19:00:35 UTC (rev 10251)
@@ -92,7 +92,6 @@
class="rich-fileupload-hidden"
id="#{clientId}:file"
name="#{clientId}:file"
- onmousedown="$('#{clientId}').component.createFrame();"
onchange="return
$('#{clientId}').component.add(this);"/>
</div>
</div>