Author: andrei_exadel
Date: 2008-04-24 12:08:27 -0400 (Thu, 24 Apr 2008)
New Revision: 8137
Modified:
trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
Log:
Modified: trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-04-24 16:06:00
UTC (rev 8136)
+++ trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-04-24 16:08:27
UTC (rev 8137)
@@ -25,7 +25,9 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.rmi.server.UID;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -65,16 +67,22 @@
this.flag = flag;
}
- public void listener(UploadEvent event) throws Exception{
+ public void listener(UploadEvent event){
UploadItem item = event.getUploadItem();
System.out.println("File : '" + item.getFileName() + "' was
uploaded");
- if (item.isFile()) {
+ if (item.isTempFile()) {
File file = item.getFile();
System.out.println("Absolute Path : '" + file.getAbsolutePath() +
"'!");
+ file.delete();
}else {
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- b.write(item.getData());
- System.out.println(b.toString());
+ try {
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ b.write(item.getData());
+ System.out.println(b.toString());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
}
}