Author: andrei_exadel
Date: 2008-07-07 09:20:46 -0400 (Mon, 07 Jul 2008)
New Revision: 9427
Modified:
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
Log:
fix stop functionality under flash
Modified:
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
---
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2008-07-07
13:15:19 UTC (rev 9426)
+++
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2008-07-07
13:20:46 UTC (rev 9427)
@@ -114,15 +114,34 @@
MultipartRequest multipartRequest = map.get(uid);
clientId = clientId + ":file";
+ boolean isFlash = false;
if (multipartRequest.getFileName(clientId) == null) {
- clientId = "Filedata"; // Flesh mode
+ clientId = "Filedata"; // Flash mode
+ isFlash = true;
}
+
String fileName = multipartRequest.getFileName(clientId);
Object file = multipartRequest.getFile(clientId);
+
+ if (isFlash) {
+ try {
+ int actualSize = multipartRequest.getFileSize(clientId);
+ int clientSize =
Integer.parseInt(requestParameterMap.get("_richfaces_size"));
+
+ if (actualSize != clientSize) {
+ return; // File uploading has been stopped on the client side
+ }
+ }catch (Exception e) {
+ return;
+ }
+ }
+
fileUpload.setLocalFileName(fileName);
fileUpload.setLocalContentType(multipartRequest.getFileContentType(clientId));
+
+
onUploadComplete(context, file, fileUpload);
}
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-07-07
13:15:19 UTC (rev 9426)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-07-07
13:20:46 UTC (rev 9427)
@@ -700,8 +700,11 @@
this.runUpload = false;
if (this.activeEntry) {
- this.upload_stopped = true;
- this.activeEntry.stop();
+ if(!this.isFlash) {
+ this.activeEntry.stop();
+ }else {
+ this._flashStop();
+ }
}
return false;
},
@@ -1151,7 +1154,7 @@
},
_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";
+ var getParams = "_richfaces_upload_uid="+ encodeURI(entry.uid) +
"&id=" + this.id +
"&_richfaces_upload_file_indicator=true&_richfaces_size="+entry.size+"&_richfaces_send_http_error=true";
if (/\?/.test(url)) {
var i = url.indexOf("?");
url = url.substring(0, i) + ";jsessionid=" + this.sessionId +
url.substring(i) + "&" + getParams;
@@ -1190,13 +1193,13 @@
},
-/* _flashStop: function() {
+ _flashStop: function() {
if (this.uploadIndex>=0) {
- //this.flashComponent.cancelUploadFile(this.uploadIndex);
- this.activeEntry.stop();
+ this.flashComponent.cancelUploadFile(this.uploadIndex);
+ //this.activeEntry.stop();
this._flashError(FileUploadEntry.UPLOAD_CANCELED);
}
- },*/
+ },
_flashOnProgress: function (bytesLoaded, bytesTotal)
{