Author: andrei_exadel
Date: 2008-03-31 07:18:50 -0400 (Mon, 31 Mar 2008)
New Revision: 7453
Modified:
trunk/ui/fileUpload/src/main/config/component/fileUpload.xml
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
Log:
RF-2871
Modified: trunk/ui/fileUpload/src/main/config/component/fileUpload.xml
===================================================================
--- trunk/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-03-31 11:17:07 UTC
(rev 7452)
+++ trunk/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-03-31 11:18:50 UTC
(rev 7453)
@@ -240,6 +240,16 @@
<description>A JavaScript event handler called when the file upload was
interrupted according to any errors</description>
</property>
<property>
+ <name>ontyperejected</name>
+ <classname>java.lang.String</classname>
+ <description>A JavaScript event handler called when the file type was rejected
according to file types allowed</description>
+ </property>
+ <property>
+ <name>onsizerejected</name>
+ <classname>java.lang.String</classname>
+ <description>A JavaScript event handler called when the file uploading was
rejected by fiel size overflow</description>
+ </property>
+ <property>
<name>addControlLabel</name>
<classname>java.lang.String</classname>
<description>Defines a label for an add button</description>
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-03-31
11:17:07 UTC (rev 7452)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-03-31
11:18:50 UTC (rev 7453)
@@ -552,7 +552,12 @@
add: function(elt) {
if (this.disabled) return;
- if (!this.checkFileType(elt.value)) return;
+ if (!this.checkFileType(elt.value)) {
+ if(this.events.ontyperejected) {
+ this.element.fire("rich:ontyperejected", {});
+ }
+ return;
+ }
var newEntry = new FileUploadEntry(elt, this);
this.entries.push(newEntry);
@@ -828,6 +833,12 @@
if (newState == FileUploadEntry.UPLOAD_SUCCESS || newState ==
FileUploadEntry.UPLOAD_SIZE_ERROR) {
//todo clear completed
+
+ if (newState == FileUploadEntry.UPLOAD_SIZE_ERROR) {
+ if(this.events.onsizerejected) {
+ this.element.fire("rich:onsizerejected", {});
+ }
+ }
if (newState == FileUploadEntry.UPLOAD_SUCCESS) {
this.uploadedCount++;
Modified: trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
--- trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-03-31
11:17:07 UTC (rev 7452)
+++ trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-03-31
11:18:50 UTC (rev 7453)
@@ -176,7 +176,9 @@
onupload : #{this:getAsEventHandler(context, component, "onupload")},
onuploadcomplete : #{this:getAsEventHandler(context, component,
"onuploadcomplete")},
onuploadcanceled : #{this:getAsEventHandler(context, component,
"onuploadcanceled")},
- onerror : #{this:getAsEventHandler(context, component, "onerror")}
+ onerror : #{this:getAsEventHandler(context, component, "onerror")},
+ ontyperejected : #{this:getAsEventHandler(context, component,
"ontyperejected")},
+ onsizerejected : #{this:getAsEventHandler(context, component,
"onsizerejected")}
};
new FileUpload('#{clientId}','#{formId}',#{this:getStopScript(context,
component)}, #{this:getFileSizeScript(context, component)}
,'#{this:getProgressBarId(context, component)}', FileUpload.CLASSES,
#{this:getLabelMarkup(context, component)}, #{maxCount}, events,
#{component.attributes["disabled"]}, #{this:getAcceptedTypes(context,
component)},
{'autoclear':#{component.attributes["autoclear"]},'autoUpload':#{component.attributes["immediateUpload"]}},#{this:_getLabels(labels)});