Author: nbelaevski
Date: 2009-02-20 17:52:53 -0500 (Fri, 20 Feb 2009)
New Revision: 12709
Added:
trunk/ui/fileUpload/src/main/config/faces/
trunk/ui/fileUpload/src/main/config/faces/phase-listener.inc
trunk/ui/fileUpload/src/main/java/org/richfaces/component/FileUploadPhaselistener.java
Log:
https://jira.jboss.org/jira/browse/RF-4187
Added: trunk/ui/fileUpload/src/main/config/faces/phase-listener.inc
===================================================================
--- trunk/ui/fileUpload/src/main/config/faces/phase-listener.inc
(rev 0)
+++ trunk/ui/fileUpload/src/main/config/faces/phase-listener.inc 2009-02-20 22:52:53 UTC
(rev 12709)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.1//EN"
+
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <lifecycle>
+ <phase-listener>org.richfaces.component.FileUploadPhaselistener</phase-listener>
+ </lifecycle>
+</faces-config>
+
Added:
trunk/ui/fileUpload/src/main/java/org/richfaces/component/FileUploadPhaselistener.java
===================================================================
---
trunk/ui/fileUpload/src/main/java/org/richfaces/component/FileUploadPhaselistener.java
(rev 0)
+++
trunk/ui/fileUpload/src/main/java/org/richfaces/component/FileUploadPhaselistener.java 2009-02-20
22:52:53 UTC (rev 12709)
@@ -0,0 +1,73 @@
+/**
+ * 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.component;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.ajax4jsf.request.MultipartRequest;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+public class FileUploadPhaselistener implements PhaseListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3243506714022741982L;
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
+ */
+ public void afterPhase(PhaseEvent event) {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
+ */
+ public void beforePhase(PhaseEvent event) {
+ FacesContext facesContext = event.getFacesContext();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Object request = externalContext.getRequest();
+ if (request instanceof MultipartRequest) {
+ MultipartRequest multipartRequest = (MultipartRequest) request;
+ multipartRequest.parseRequest();
+ if (multipartRequest.isStopped()) {
+ facesContext.responseComplete();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return PhaseId.RESTORE_VIEW;
+ }
+
+}