Author: andrei_exadel
Date: 2008-02-05 10:44:30 -0500 (Tue, 05 Feb 2008)
New Revision: 5825
Added:
trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp
Removed:
trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp
trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.xhtml
trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index2.jsp
Modified:
trunk/sandbox/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/fileUploadDemo/src/main/webapp/index.jsp
Log:
demo site refactoring
Modified: trunk/sandbox/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-02-05
15:37:21 UTC (rev 5824)
+++ trunk/sandbox/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-02-05
15:44:30 UTC (rev 5825)
@@ -21,10 +21,12 @@
package org.richfaces;
-import java.io.IOException;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
-import org.richfaces.org.jboss.seam.ui.component.UIFileUpload;
+import javax.faces.event.ActionEvent;
/**
* @author $Autor$
@@ -32,33 +34,41 @@
*/
public class Bean {
- private UIFileUpload fileUpload;
+ private Map<String,InputStream> data = new HashMap<String, InputStream>();
+
+ public void action(ActionEvent event) {
+ try {
+ if (data != null) {
+ for (String name : data.keySet()) {
+ System.out.println("\nFile Name : " + name);
+ InputStream stream = data.get(name);
+ byte[] buffer = new byte[4096];
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ int read;
+ while ((read = stream.read(buffer)) != -1) {
+ b.write(buffer, 0, read);
+ System.out.println(b.toString());
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.getMessage();
+ }
+ }
- public UIFileUpload getFileUpload() {
- return fileUpload;
+ /**
+ * @return the data
+ */
+ public Map<String, InputStream> getData() {
+ return data;
}
- public void setFileUpload(UIFileUpload fileUpload) {
- this.fileUpload = fileUpload;
+ /**
+ * @param data the data to set
+ */
+ public void setData(Map<String, InputStream> data) {
+ this.data = data;
}
- public void printFile() {
- int i = -1;
- int count = 0;
- InputStream stream = fileUpload.getLocalInputStream();
- if (stream != null) {
- do {
- try {
- i = stream.read();
- count++;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //System.out.print((char) i);
- } while (i != -1);
- System.out.println(String.format("%d bytes read", count));
- }
-
- }
+
}
\ No newline at end of file
Modified: trunk/sandbox/samples/fileUploadDemo/src/main/webapp/index.jsp
===================================================================
--- trunk/sandbox/samples/fileUploadDemo/src/main/webapp/index.jsp 2008-02-05 15:37:21 UTC
(rev 5824)
+++ trunk/sandbox/samples/fileUploadDemo/src/main/webapp/index.jsp 2008-02-05 15:44:30 UTC
(rev 5825)
@@ -5,7 +5,7 @@
<head></head>
<body>
- <jsp:forward page="/pages/index2.jsf" />
+ <jsp:forward page="/pages/index.jsf" />
</body>
</html>
\ No newline at end of file
Deleted: trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp 2008-02-05
15:37:21 UTC (rev 5824)
+++ trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp 2008-02-05
15:44:30 UTC (rev 5825)
@@ -1,30 +0,0 @@
-<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
-<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j"%>
-<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/ui/fileUpload"
- prefix="fu"%>
-<html>
-<head>
-<title></title>
-</head>
-<body>
-<script language="javascript"><!--
-function loader_end() {
-alert("lll");
-}
-//-->
-</script>
-<div style="display: none;"><iframe name="loader"
- onload="loader_end()"></iframe></div>
-
-<f:view>
- <h:form target="loader" enctype="multipart/form-data">
- <fu:fileUpload binding="#{bean.fileUpload}"
- onclick="window.status=this.value" />
- <br />
- <h:commandButton action="#{bean.printFile}"
value="Submit"></h:commandButton>
- <a4j:commandButton action="#{bean.printFile}"
value="Submit"></a4j:commandButton>
- </h:form>
-</f:view>
-</body>
-</html>
Copied: trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp (from rev
5815, trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index2.jsp)
===================================================================
--- trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp
(rev 0)
+++ trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.jsp 2008-02-05
15:44:30 UTC (rev 5825)
@@ -0,0 +1,24 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j"%>
+<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/ui/fileUpload"
+ prefix="fu"%>
+<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/ui/progressBar"
prefix="progressBar" %>
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<f:view>
+<h:form>
+<fu:fileUpload data="#{bean.data}">
+ <f:facet name="progress">
+ <progressBar:progressBar style="height: 10px; width: 300px;">
+ </progressBar:progressBar>
+ </f:facet>
+</fu:fileUpload><br/><br/><br/>
+<h:commandButton actionListener="#{bean.action}" style="font-weight:
bold; width: 300px;" value="Print file content in
console"></h:commandButton>
+</h:form>
+</f:view>
+</body>
+</html>
Deleted: trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.xhtml 2008-02-05
15:37:21 UTC (rev 5824)
+++ trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index.xhtml 2008-02-05
15:44:30 UTC (rev 5825)
@@ -1,12 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
-
xmlns:c="http://java.sun.com/jsp/jstl/core"
- >
- <f:view>
-
- </f:view>
-</html>
\ No newline at end of file
Deleted: trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index2.jsp
===================================================================
--- trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index2.jsp 2008-02-05
15:37:21 UTC (rev 5824)
+++ trunk/sandbox/samples/fileUploadDemo/src/main/webapp/pages/index2.jsp 2008-02-05
15:44:30 UTC (rev 5825)
@@ -1,24 +0,0 @@
-<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
-<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j"%>
-<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/ui/fileUpload"
- prefix="fu"%>
-<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/ui/progressBar"
prefix="progressBar" %>
-<html>
-<head>
-<title></title>
-</head>
-<body>
-<f:view>
-<h:form>
-<fu:fileUpload>
- <f:facet name="progress">
- <progressBar:progressBar style="height: 10px; width: 300px;">
- </progressBar:progressBar>
- </f:facet>
-</fu:fileUpload><br/>
-<h:commandButton value="Submit"></h:commandButton>
-</h:form>
-</f:view>
-</body>
-</html>