Author: andrei_exadel
Date: 2008-08-19 05:25:17 -0400 (Tue, 19 Aug 2008)
New Revision: 10135
Modified:
trunk/framework/api/src/main/java/org/richfaces/event/UploadEvent.java
trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java
Log:
refactoring
Modified: trunk/framework/api/src/main/java/org/richfaces/event/UploadEvent.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/event/UploadEvent.java 2008-08-19
09:25:11 UTC (rev 10134)
+++ trunk/framework/api/src/main/java/org/richfaces/event/UploadEvent.java 2008-08-19
09:25:17 UTC (rev 10135)
@@ -20,6 +20,8 @@
*/
package org.richfaces.event;
+import java.util.List;
+
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
@@ -28,13 +30,12 @@
public class UploadEvent extends FacesEvent{
-
private static final long serialVersionUID = -7645197191376210068L;
- private UploadItem uploadItem = null;
+ private List<UploadItem> uploadItems = null;
- public UploadEvent(UIComponent component, UploadItem uploadItem) {
+ public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
super(component);
- this.uploadItem = uploadItem;
+ this.uploadItems = uploadItems;
}
@@ -47,10 +48,29 @@
}
- /**
+ /**Returns UploadItem instance.
+ * Returns first element of list of UploadItems in case of multiple upload.
* @return the uploadItem
*/
public UploadItem getUploadItem() {
- return uploadItem;
+ if (uploadItems != null && uploadItems.size() > 0) {
+ return uploadItems.get(0);
+ }
+ return null;
}
+
+ /**
+ * Return list of UploadItems
+ * @return the uploadItem
+ */
+ public List<UploadItem> getUploadItems() {
+ return uploadItems;
+ }
+
+ /** Return true if multiple files were uploaded with form
+ * @return
+ */
+ public boolean isMultiUpload() {
+ return (uploadItems != null && uploadItems.size() > 1);
+ }
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java 2008-08-19
09:25:11 UTC (rev 10134)
+++ trunk/framework/api/src/main/java/org/richfaces/model/UploadItem.java 2008-08-19
09:25:17 UTC (rev 10135)
@@ -9,8 +9,6 @@
import java.io.File;
import java.io.Serializable;
-import javax.faces.FacesException;
-
/**
* Class provides object holder for file uploaded.
* Instance of this type will be returned by UploadEvent after appropriate listener
called after uploading has been completed.
@@ -36,12 +34,16 @@
/** File byte content */
private byte [] bytes;
+ /** File size */
+ private int fileSize;
+
/**
* Constructor for the UploadItem
*/
- public UploadItem(String fileName, String contentType, Object file) {
+ public UploadItem(String fileName, int fileSize, String contentType, Object file) {
this.fileName = fileName;
this.contentType = contentType;
+ this.fileSize = fileSize;
if (null != file) {
if (file.getClass().isAssignableFrom(File.class)) {
this.file = (File) file;
@@ -93,6 +95,13 @@
public String getContentType() {
return contentType;
}
+
+ /**
+ * @return the fileSize
+ */
+ public int getFileSize() {
+ return fileSize;
+ }
}
Show replies by date