Author: ilya_shaikovsky
Date: 2010-12-31 03:29:12 -0500 (Fri, 31 Dec 2010)
New Revision: 20855
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml
Log:
https://issues.jboss.org/browse/RF-9974
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java 2010-12-31
07:39:15 UTC (rev 20854)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java 2010-12-31
08:29:12 UTC (rev 20855)
@@ -1,15 +1,16 @@
package org.richfaces.demo.fileupload;
-import org.richfaces.event.FileUploadEvent;
-import org.richfaces.model.UploadedFile;
-
-import javax.faces.bean.ManagedBean;
-import javax.faces.bean.SessionScoped;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.ArrayList;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.event.FileUploadEvent;
+import org.richfaces.model.UploadedFile;
+
/**
* @author Ilya Shaikovsky
*
@@ -18,30 +19,16 @@
@SessionScoped
public class FileUploadBean implements Serializable {
- private ArrayList<UploadedImage> files = new ArrayList<UploadedImage>();
+ private ArrayList<UploadedFile> files = new ArrayList<UploadedFile>();
private int uploadsAvailable = 5;
- private boolean autoUpload = false;
- private boolean useFlash = false;
- public int getSize() {
- if (getFiles().size() > 0) {
- return getFiles().size();
- } else {
- return 0;
- }
- }
-
public void paint(OutputStream stream, Object object) throws IOException {
stream.write(getFiles().get((Integer) object).getData());
+ stream.close();
}
public void listener(FileUploadEvent event) throws Exception {
- UploadedFile item = event.getUploadedFile();
- UploadedImage file = new UploadedImage();
- file.setLength(item.getData().length);
- file.setName(item.getName());
- file.setData(item.getData());
- files.add(file);
+ files.add(event.getUploadedFile());
uploadsAvailable--;
}
@@ -51,18 +38,26 @@
return null;
}
- public long getTimeStamp() {
- return System.currentTimeMillis();
+ public int getSize() {
+ if (getFiles().size() > 0) {
+ return getFiles().size();
+ } else {
+ return 0;
+ }
}
- public ArrayList<UploadedImage> getFiles() {
+ public ArrayList<UploadedFile> getFiles() {
return files;
}
- public void setFiles(ArrayList<UploadedImage> files) {
+ public void setFiles(ArrayList<UploadedFile> files) {
this.files = files;
}
+ public long getTimeStamp() {
+ return System.currentTimeMillis();
+ }
+
public int getUploadsAvailable() {
return uploadsAvailable;
}
@@ -71,20 +66,4 @@
this.uploadsAvailable = uploadsAvailable;
}
- public boolean isAutoUpload() {
- return autoUpload;
- }
-
- public void setAutoUpload(boolean autoUpload) {
- this.autoUpload = autoUpload;
- }
-
- public boolean isUseFlash() {
- return useFlash;
- }
-
- public void setUseFlash(boolean useFlash) {
- this.useFlash = useFlash;
- }
-
}
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml 2010-12-31
07:39:15 UTC (rev 20854)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml 2010-12-31
08:29:12 UTC (rev 20855)
@@ -36,7 +36,7 @@
var="file" rowKeyVar="row">
<rich:panel bodyClass="rich-laguna-panel-no-header">
<h:panelGrid columns="2">
- <a4j:mediaOutput element="img" mimeType="#{file.mime}"
+ <a4j:mediaOutput element="img" mimeType="image/jpeg"
createContent="#{fileUploadBean.paint}" value="#{row}"
style="width:100px; height:100px;" cacheable="false">
<f:param value="#{fileUploadBean.timeStamp}" name="time"
/>
@@ -45,7 +45,7 @@
<h:outputText value="File Name:" />
<h:outputText value="#{file.name}" />
<h:outputText value="File Length(bytes):" />
- <h:outputText value="#{file.length}" />
+ <h:outputText value="#{file.size}" />
</h:panelGrid>
</h:panelGrid>
</rich:panel>