Author: andrei_exadel
Date: 2008-02-28 11:24:32 -0500 (Thu, 28 Feb 2008)
New Revision: 6424
Modified:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java
Log:
refactoring after Upload event changed
Modified:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java 2008-02-28
16:23:01 UTC (rev 6423)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java 2008-02-28
16:24:32 UTC (rev 6424)
@@ -1,6 +1,5 @@
package org.richfaces.org.jboss.seam.ui.renderkit;
-import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -79,7 +78,7 @@
* @param map
* @return
*/
- private boolean checkFileCount (UIFileUpload fileUpload, Map<String, File> map)
{
+ private boolean checkFileCount (UIFileUpload fileUpload, Map<String, Object>
map) {
Integer max = fileUpload.getMaxFilesQuantity();
if (map != null && map.size() >= max) {
fileUpload.reset();
@@ -95,12 +94,12 @@
* @param file
*/
@SuppressWarnings("unchecked")
- private void storeData(FacesContext context, UIFileUpload fileUpload, File file) {
+ private void storeData(FacesContext context, UIFileUpload fileUpload, Object file) {
ValueExpression data = fileUpload.getValueExpression("data");
if (data != null) {
Class clazz = data.getType(context.getELContext());
if (clazz.isAssignableFrom(Map.class)) {
- Map<String, File> map = (Map<String, File>)
data.getValue(context.getELContext());
+ Map<String, Object> map = (Map<String, Object>)
data.getValue(context.getELContext());
if (checkFileCount(fileUpload, map)) {
map.put(fileUpload.getLocalFileName(), file);
}else {
@@ -116,7 +115,7 @@
* @param file
* @param fileUpload
*/
- private void onUploadComplete(FacesContext context, File file,
+ private void onUploadComplete(FacesContext context, Object file,
UIFileUpload fileUpload) {
storeData(context, fileUpload, file);
try {
Modified:
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java
===================================================================
---
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java 2008-02-28
16:23:01 UTC (rev 6423)
+++
trunk/sandbox/ui/fileUpload/src/main/java/org/richfaces/org/jboss/seam/web/MultipartRequest.java 2008-02-28
16:24:32 UTC (rev 6424)
@@ -123,8 +123,13 @@
super(name);
}
- public File getFile() {
- return tempFile;
+ public Object getFile() {
+ if (null != tempFile) {
+ return tempFile;
+ }else if (null != bOut) {
+ return bOut.toByteArray();
+ }
+ return null;
}
public String getFilename() {
@@ -566,7 +571,7 @@
.getContentType() : null;
}
- public File getFile(String name) {
+ public Object getFile(String name) {
Param p = getParam(name);
return (p != null && p instanceof FileParam) ? ((FileParam) p)
.getFile() : null;
Show replies by date