Author: andrei_exadel
Date: 2008-04-11 06:52:33 -0400 (Fri, 11 Apr 2008)
New Revision: 7759
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-3023
Modified: trunk/ui/fileUpload/src/main/config/component/fileUpload.xml
===================================================================
--- trunk/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-04-11 10:19:07 UTC
(rev 7758)
+++ trunk/ui/fileUpload/src/main/config/component/fileUpload.xml 2008-04-11 10:52:33 UTC
(rev 7759)
@@ -213,6 +213,14 @@
<defaultvalue>false</defaultvalue>
</property>
<property>
+ <name>noDuplicate</name>
+ <classname>boolean</classname>
+ <description>
+ Defines if component should allow to add files that was already in list
+ </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
<name>acceptedTypes</name>
<classname>java.lang.String</classname>
<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-04-11
10:19:07 UTC (rev 7758)
+++
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2008-04-11
10:52:33 UTC (rev 7759)
@@ -552,10 +552,21 @@
}
return false;
},
+
+ checkDuplicated: function (elt) {
+ if (!this.options.noDuplicate) return true;
+ var fileName = elt.value;
+ for (var i = 0; i < this.entries.length; i++) {
+ if (fileName == this.entries[i].fileInput.value) {
+ return false;
+ }
+ }
+ return true;
+ },
add: function(elt) {
if (this.disabled) return;
- if (!this.checkFileType(elt.value)) {
+ if (!this.checkFileType(elt.value) || !this.checkDuplicated(elt)) {
if(this.events.ontyperejected) {
this.element.fire("rich:ontyperejected", {});
}
Modified: trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx
===================================================================
--- trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-04-11
10:19:07 UTC (rev 7758)
+++ trunk/ui/fileUpload/src/main/templates/org/richfaces/fileUpload.jspx 2008-04-11
10:52:33 UTC (rev 7759)
@@ -183,7 +183,7 @@
onclear : #{this:getAsEventHandler(context, component, "onclear")}
};
- new
FileUpload('#{clientId}','#{formId}','#{actionUrl}',#{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)},#{this:getChildrenParams(context,
component)});
+ new
FileUpload('#{clientId}','#{formId}','#{actionUrl}',#{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"]},'noDuplicate':#{component.attributes["noDuplicate"]}},#{this:_getLabels(labels)},#{this:getChildrenParams(context,
component)});
</script>
</span>
<f:call name="utils.encodeEndFormIfNessesary" />