Author: konstantin.mishin
Date: 2010-12-06 13:16:22 -0500 (Mon, 06 Dec 2010)
New Revision: 20419
Modified:
trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
Log:
RF-9497
Modified: trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06
18:00:33 UTC (rev 20418)
+++ trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06
18:16:22 UTC (rev 20419)
@@ -20,8 +20,6 @@
*/
package org.richfaces.event;
-import java.util.List;
-
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
@@ -31,11 +29,11 @@
public class UploadEvent extends FacesEvent {
private static final long serialVersionUID = -7645197191376210068L;
- private List<UploadItem> uploadItems = null;
+ private UploadItem uploadItem = null;
- public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
+ public UploadEvent(UIComponent component, UploadItem uploadItem) {
super(component);
- this.uploadItems = uploadItems;
+ this.uploadItem = uploadItem;
}
public boolean isAppropriateListener(FacesListener listener) {
@@ -52,29 +50,6 @@
* @return the uploadItem
*/
public UploadItem getUploadItem() {
- if (uploadItems != null && uploadItems.size() > 0) {
- return uploadItems.get(0);
- }
- return null;
+ return uploadItem;
}
-
- /**
- * Return list of UploadItems
- *
- * @return the uploadItem
- * @since 3.2.2
- */
- public List<UploadItem> getUploadItems() {
- return uploadItems;
- }
-
- /**
- * Return true if multiple files were uploaded with form
- *
- * @return boolean
- * @since 3.2.2
- */
- public boolean isMultiUpload() {
- return uploadItems != null && uploadItems.size() > 1;
- }
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06
18:00:33 UTC (rev 20418)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06
18:16:22 UTC (rev 20419)
@@ -26,6 +26,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
import org.richfaces.request.MultipartRequest;
/**
@@ -38,9 +39,11 @@
protected void doDecode(FacesContext context, UIComponent component) {
ExternalContext externalContext = context.getExternalContext();
Object request = externalContext.getRequest();
- if (request instanceof MultipartRequest
- &&
externalContext.getRequestParameterMap().containsKey(component.getClientId(context))) {
- component.queueEvent(new UploadEvent(component, ((MultipartRequest)
request).getUploadItems()));
+ if (request instanceof MultipartRequest) {
+ UploadItem uploadItem = ((MultipartRequest)
request).getUploadItem(component.getClientId(context));
+ if (uploadItem != null) {
+ component.queueEvent(new UploadEvent(component, uploadItem));
+ }
}
}
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06
18:00:33 UTC (rev 20418)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06
18:16:22 UTC (rev 20419)
@@ -536,31 +536,6 @@
return (p != null && p instanceof FileParam) ? ((FileParam) p).getData()
: null;
}
- public InputStream getFileInputStream(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam)
p).getInputStream() : null;
- }
-
- public String getFileContentType(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam)
p).getContentType() : null;
- }
-
- public Object getFile(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getFile()
: null;
- }
-
- public String getFileName(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam)
p).getFilename() : null;
- }
-
- public int getFileSize(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam)
p).getFileSize() : -1;
- }
-
@Override
public String getParameter(String name) {
Param p = getParam(name);
@@ -623,12 +598,15 @@
return params;
}
- public List<UploadItem> getUploadItems() {
- List<UploadItem> uploadItems = new ArrayList<UploadItem>();
- for (String k : keys) {
- uploadItems.add(new UploadItem(getFileName(k), getFileSize(k),
getFileContentType(k), getFile(k)));
+ public UploadItem getUploadItem(String name) {
+ Param param = getParam(name);
+ if (param instanceof FileParam) {
+ FileParam fileParam = (FileParam) param;
+ return new UploadItem(fileParam.getFilename(), fileParam.getFileSize(),
fileParam.getContentType(),
+ fileParam.getFile());
+ } else {
+ return null;
}
- return uploadItems;
}
public boolean isFormUpload() {