Author: konstantin.mishin
Date: 2010-12-13 11:48:37 -0500 (Mon, 13 Dec 2010)
New Revision: 20534
Added:
trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadEvent.java
Removed:
trunk/core/api/src/main/java/org/richfaces/model/UploadItem.java
trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
Modified:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java
Log:
RF-9988
Deleted: trunk/core/api/src/main/java/org/richfaces/model/UploadItem.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/model/UploadItem.java 2010-12-13 16:24:19
UTC (rev 20533)
+++ trunk/core/api/src/main/java/org/richfaces/model/UploadItem.java 2010-12-13 16:48:37
UTC (rev 20534)
@@ -1,125 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.richfaces.model;
-
-import java.io.File;
-import java.io.Serializable;
-
-/**
- * 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.
- *
- * @author "Andrey Markavtsov"
- *
- */
-public class UploadItem implements Serializable {
-
- /**
- * Serial id
- */
- private static final long serialVersionUID = -111723029745124147L;
-
- /** File byte content */
- private byte[] bytes;
-
- /** Content type */
- private String contentType;
-
- /** java.io.File instance */
- private File file;
-
- /** Users file name */
- private String fileName;
-
- /** File size */
- private int fileSize;
-
- /**
- * Constructor for the UploadItem
- */
- 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;
- } else if (file.getClass().isAssignableFrom(byte[].class)) {
- this.bytes = (byte[]) file;
- }
- }
- }
-
- /**
- * Return true if file is holding as java.io.File type.
- * If true getFile method should be invoked to get file uploaded.
- * In another case getData method should be invoked to get file's bytes.
- * @return
- */
- public boolean isTempFile() {
- return null != file;
- }
-
- /**
- * This method should called only in case of TRUE value returned by {@link
#isTempFile()} method.
- * Otherwise null value will be returned by this method.
- * @return the file
- */
- public File getFile() {
- return file;
- }
-
- /**
- * This method should called only in case of FALSE value returned by {@link
#isTempFile()} method.
- * Otherwise null value will be returned by this method.
- * @return the bytes
- * @throws Exception
- */
- public byte[] getData() {
- return bytes;
- }
-
- /**
- * @return the fileName
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
- * @return the contentType
- */
- public String getContentType() {
- return contentType;
- }
-
- /**
- * @return the fileSize
- */
- public int getFileSize() {
- return fileSize;
- }
-}
Modified: trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
===================================================================
---
trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-13
16:24:19 UTC (rev 20533)
+++
trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -27,7 +27,7 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.AjaxBehaviorEvent;
-import org.richfaces.event.UploadEvent;
+import org.richfaces.event.FileUploadEvent;
import org.richfaces.model.UploadedFile;
/**
@@ -51,7 +51,7 @@
// stream.write(item.getData());
// }
- public void listener(UploadEvent event) throws Exception {
+ public void listener(FileUploadEvent event) throws Exception {
file = event.getUploadedFile();
}
Copied: trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadEvent.java (from
rev 20520, trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java)
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadEvent.java
(rev 0)
+++ trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadEvent.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.model.UploadedFile;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FileUploadEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -7645197191376210068L;
+ private UploadedFile uploadedFile = null;
+
+ public FileUploadEvent(UIComponent component, UploadedFile uploadedFile) {
+ super(component);
+ this.uploadedFile = uploadedFile;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof FileUploadListener;
+ }
+
+ public void processListener(FacesListener listener) {
+ ((FileUploadListener) listener).processUpload(this);
+ }
+
+ public UploadedFile getUploadedFile() {
+ return uploadedFile;
+ }
+}
Modified: trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java
===================================================================
---
trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java 2010-12-13
16:24:19 UTC (rev 20533)
+++
trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -25,5 +25,5 @@
public interface FileUploadListener extends FacesListener {
- public void processUpload(UploadEvent event);
+ public void processUpload(FileUploadEvent event);
}
Deleted: 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-13
16:24:19 UTC (rev 20533)
+++ trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.model.UploadedFile;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class UploadEvent extends FacesEvent {
-
- private static final long serialVersionUID = -7645197191376210068L;
- private UploadedFile uploadedFile = null;
-
- public UploadEvent(UIComponent component, UploadedFile uploadedFile) {
- super(component);
- this.uploadedFile = uploadedFile;
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof FileUploadListener;
- }
-
- public void processListener(FacesListener listener) {
- ((FileUploadListener) listener).processUpload(this);
- }
-
- public UploadedFile getUploadedFile() {
- return uploadedFile;
- }
-}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-13
16:24:19 UTC (rev 20533)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -91,7 +91,7 @@
/**
* <p>Add a new {@link FileUploadListener} to the set of listeners
- * interested in being notified when {@link org.richfaces.UploadEvent}s
occur.</p>
+ * interested in being notified when {@link org.richfaces.FileUploadEvent}s
occur.</p>
*
* @param listener The {@link FileUploadListener} to be added
* @throws NullPointerException if <code>listener</code>
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-13
16:24:19 UTC (rev 20533)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -25,7 +25,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import org.richfaces.event.UploadEvent;
+import org.richfaces.event.FileUploadEvent;
import org.richfaces.model.UploadedFile;
import org.richfaces.request.MultipartRequest;
@@ -42,7 +42,7 @@
if (request instanceof MultipartRequest) {
UploadedFile file = ((MultipartRequest)
request).getUploadedFile(component.getClientId(context));
if (file != null) {
- component.queueEvent(new UploadEvent(component, file));
+ component.queueEvent(new FileUploadEvent(component, file));
}
}
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java 2010-12-13
16:24:19 UTC (rev 20533)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java 2010-12-13
16:48:37 UTC (rev 20534)
@@ -33,7 +33,7 @@
import org.richfaces.component.AbstractFileUpload;
import org.richfaces.event.FileUploadListener;
-import org.richfaces.event.UploadEvent;
+import org.richfaces.event.FileUploadEvent;
/**
* @author Konstantin Mishin
@@ -54,12 +54,12 @@
public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
if (meta.isTargetInstanceOf(AbstractFileUpload.class)) {
if ("fileUploadListener".equals(name)) {
- return new MethodMetadata(attribute, UploadEvent.class) {
+ return new MethodMetadata(attribute, FileUploadEvent.class) {
@Override
public void applyMetadata(final FaceletContext ctx, Object
instance) {
final MethodExpression expression =
getMethodExpression(ctx);
((AbstractFileUpload) instance).addFileUploadListener(new
FileUploadListener(){
- public void processUpload(UploadEvent event) {
+ public void processUpload(FileUploadEvent event) {
expression.invoke(ctx.getFacesContext().getELContext(), new Object[] {event});
}
});