Author: konstantin.mishin
Date: 2010-10-25 12:36:34 -0400 (Mon, 25 Oct 2010)
New Revision: 19668
Added:
sandbox/trunk/examples/fileupload-demo/src/main/java/org/
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
Modified:
sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml
Log:
RF-9501
Added:
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
===================================================================
---
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
(rev 0)
+++
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-10-25
16:36:34 UTC (rev 19668)
@@ -0,0 +1,52 @@
+/*
+ * 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.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class FileUploadBean {
+
+ private UploadItem item;
+
+ public UploadItem getItem() {
+ return item;
+ }
+
+// public void paint(OutputStream stream, Object object) throws IOException {
+// stream.write(item.getData());
+// }
+
+ public void listener(UploadEvent event) throws Exception {
+ item = event.getUploadItem();
+ }
+
+}
Modified: sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml
===================================================================
--- sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml 2010-10-25
16:29:09 UTC (rev 19667)
+++ sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml 2010-10-25
16:36:34 UTC (rev 19668)
@@ -4,7 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:fu="http://richfaces.org/fileupload">
+
xmlns:fu="http://richfaces.org/fileUpload">
<!--
JBoss, Home of Professional Open Source
Copyright ${year}, Red Hat, Inc. and individual contributors
@@ -33,13 +33,22 @@
<title>Richfaces FileUpload Demo</title>
</h:head>
<h:body>
- <h:form id="form">
- <h:outputText value="Skin: "/>
+ <h:form id="form" enctype="multipart/form-data">
+ <script type="text/javascript">
+ <!--
+ var myForm = document.getElementById("form");
+ myForm.action = myForm.action + "?_richfaces_upload_uid=1";
+ //-->
+ </script>
+ <!--h:outputText value="Skin: "/>
<h:selectOneMenu value="#{skinBean.skin}"
onchange="submit();">
<f:selectItems value="#{skinBean.skins}"/>
</h:selectOneMenu>
- <br />
- <fu:fileupload />
+ <br /-->
+ <fu:fileUpload fileUploadListener="#{fileUploadBean.listener}"/>
+ <h:outputText value="File name:" />
+ <h:outputText value="#{fileUploadBean.item.fileName}" />
+ <input type="submit" />
</h:form>
</h:body>
</html>