myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r828641 - in /myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main: java/org/apache/myfaces/tobago/example/reference/Upload.java webapp/WEB-INF/faces-config.xml webapp/reference/upload.jsp
Date Thu, 22 Oct 2009 10:29:19 GMT
Author: lofwyr
Date: Thu Oct 22 10:29:19 2009
New Revision: 828641

URL: http://svn.apache.org/viewvc?rev=828641&view=rev
Log:
useful example for file upload

Added:
    myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java
Modified:
    myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/reference/upload.jsp

Added: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java?rev=828641&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java
(added)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java
Thu Oct 22 10:29:19 2009
@@ -0,0 +1,44 @@
+package org.apache.myfaces.tobago.example.reference;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class Upload {
+
+  private static final Log LOG = LogFactory.getLog(Upload.class);
+
+  private FileItem file;
+
+  public String upload() {
+    LOG.info("type=" + file.getContentType());
+    LOG.info("file=" + file.get().length);
+    LOG.info("name=" + file.getName());
+    return null;
+  }
+  
+  public FileItem getFile() {
+    return file;
+  }
+
+  public void setFile(FileItem file) {
+    this.file = file;
+  }
+}

Modified: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/faces-config.xml?rev=828641&r1=828640&r2=828641&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/faces-config.xml
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/WEB-INF/faces-config.xml
Thu Oct 22 10:29:19 2009
@@ -290,6 +290,12 @@
     <managed-bean-scope>request</managed-bean-scope>
   </managed-bean>
 
+  <managed-bean>
+    <managed-bean-name>upload</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.reference.Upload</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+  
   <navigation-rule>
     <navigation-case>
       <from-outcome>reference/intro</from-outcome>

Modified: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/reference/upload.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/reference/upload.jsp?rev=828641&r1=828640&r2=828641&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/reference/upload.jsp
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/reference/upload.jsp
Thu Oct 22 10:29:19 2009
@@ -23,15 +23,15 @@
   <jsp:body>
     <tc:box label="File Upload">
       <f:facet name="layout">
-        <tc:gridLayout columns="400px;1*" rows="fixed;1*" />
+        <tc:gridLayout columns="400px;*" rows="fixed;1*" />
       </f:facet>
 <%-- code-sniplet-start id="file" --%>
-      <tx:file label="Upload file:" />
+      <tx:file label="Upload file:" value="#{upload.file}" />
 <%-- code-sniplet-end id="file" --%>
-      <tc:cell/>
+      <tc:button label="Submit" defaultCommand="true" action="#{upload.upload}" />
 
       <tc:cell/>
       <tc:cell/>
     </tc:box>
   </jsp:body>
-</layout:overview>
\ No newline at end of file
+</layout:overview>



Mime
View raw message