Author: andrei_exadel
Date: 2008-06-30 08:34:31 -0400 (Mon, 30 Jun 2008)
New Revision: 9297
Modified:
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
Log:
file upload refactoring
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-06-30
11:39:36 UTC (rev 9296)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-06-30
12:34:31 UTC (rev 9297)
@@ -1150,22 +1150,36 @@
}
},
- _getFleshActionUrl: function (url) {
+ _flashGetActionUrl: function (url, entry) {
+ var getParams = "_richfaces_upload_uid="+ encodeURI(entry.uid) +
"&id=" + this.id +
"&_richfaces_upload_file_indicator=true&_richfaces_send_http_error=true";
if (/\?/.test(url)) {
var i = url.indexOf("?");
- url = url.substring(0, i) + ";jsessionid=" + this.sessionId +
url.substring(i);
+ url = url.substring(0, i) + ";jsessionid=" + this.sessionId +
url.substring(i) + "&" + getParams;
} else {
- url = url + ";jsessionid=" + this.sessionId;
+ url = url + ";jsessionid=" + this.sessionId + "?" + getParams;
}
return url;
- },
+ },
+ _flashGetPostParams: function () {
+ var params = '';
+ var inputs = this.form.elements;
+ var l = inputs.length;
+ for (var i = 0; i < l; i++) {
+ var input = inputs[i];
+ if (input.id != (this.id + ':file')) {
+ params = params + '&' + input.name + '=' + input.value;
+ }
+
+ }
+ return params;
+ },
+
_flashSubmitForm: function(entry) {
entry.uid = encodeURIComponent(Math.random().toString());
- var action = this._getFleshActionUrl(this.actionUrl);
- var action = action + (/\?/.test(action) ? '&_richfaces_upload_uid=' :
'?_richfaces_upload_uid=') + encodeURI(entry.uid) + "&id=" + this.id
+
"&_richfaces_upload_file_indicator=true&_richfaces_send_http_error=true";
- var size = this.flashComponent.uploadFile(this.uploadIndex,
action,"javax.faces.ViewState="
+this.form['javax.faces.ViewState'].value+"&"+this.form.id+"="+this.form.id);
+ var action = this._flashGetActionUrl(this.actionUrl, entry);
+ var size = this.flashComponent.uploadFile(this.uploadIndex, action,
this._flashGetPostParams());
if (this.labelMarkup) {
this.progressData = new ProgressData(size);
}
Show replies by date