You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/10/26 18:35:53 UTC
svn commit: r1027636 - in
/myfaces/tobago/branches/tobago-1.0.x/example/demo: ./
src/main/java/org/apache/myfaces/tobago/example/reference/
src/main/webapp/reference/
Author: lofwyr
Date: Tue Oct 26 16:35:52 2010
New Revision: 1027636
URL: http://svn.apache.org/viewvc?rev=1027636&view=rev
Log:
Makes the upload sample reasonable.
Added:
myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/UploadItem.java
Modified:
myfaces/tobago/branches/tobago-1.0.x/example/demo/pom.xml
myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java
myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/webapp/reference/upload.jsp
Modified: myfaces/tobago/branches/tobago-1.0.x/example/demo/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/demo/pom.xml?rev=1027636&r1=1027635&r2=1027636&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/pom.xml (original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/pom.xml Tue Oct 26 16:35:52 2010
@@ -124,6 +124,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.apache.myfaces.tobago</groupId>
+ <artifactId>tobago-fileupload</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.11</version>
Modified: 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=1027636&r1=1027635&r2=1027636&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/Upload.java Tue Oct 26 16:35:52 2010
@@ -21,19 +21,26 @@ import org.apache.commons.fileupload.Fil
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
+import java.util.List;
+
public class Upload {
private static final Log LOG = LogFactory.getLog(Upload.class);
private FileItem file;
+ private List<UploadItem> list = new ArrayList<UploadItem>();
+
public String upload() {
LOG.info("type=" + file.getContentType());
LOG.info("file=" + file.get().length);
LOG.info("name=" + file.getName());
+ list.add(new UploadItem(file.getName(), file.get().length, file.getContentType()));
+ file = null; // we don't need it in this demo.
return null;
}
-
+
public FileItem getFile() {
return file;
}
@@ -41,4 +48,8 @@ public class Upload {
public void setFile(FileItem file) {
this.file = file;
}
+
+ public List<UploadItem> getList() {
+ return list;
+ }
}
Added: myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/UploadItem.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/UploadItem.java?rev=1027636&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/UploadItem.java (added)
+++ myfaces/tobago/branches/tobago-1.0.x/example/demo/src/main/java/org/apache/myfaces/tobago/example/reference/UploadItem.java Tue Oct 26 16:35:52 2010
@@ -0,0 +1,60 @@
+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.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class UploadItem {
+
+ private static final Log LOG = LogFactory.getLog(UploadItem.class);
+
+ private String name;
+ private int size;
+ private String type;
+
+ public UploadItem(String name, int size, String type) {
+ this.name = name;
+ this.size = size;
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
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=1027636&r1=1027635&r2=1027636&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 Tue Oct 26 16:35:52 2010
@@ -23,15 +23,36 @@
<jsp:body>
<tc:box label="File Upload">
<f:facet name="layout">
- <tc:gridLayout columns="400px;*" rows="fixed;1*" />
+ <tc:gridLayout columns="400px;*" rows="fixed;fixed;1*"/>
</f:facet>
-<%-- code-sniplet-start id="file" --%>
- <tx:file label="Upload file:" value="#{upload.file}" />
-<%-- code-sniplet-end id="file" --%>
- <tc:button label="Submit" defaultCommand="true" action="#{upload.upload}" />
- <tc:cell/>
- <tc:cell/>
+ <tc:cell spanX="2">
+ <tc:messages/>
+ </tc:cell>
+
+ <%-- code-sniplet-start id="file" --%>
+ <tx:file label="Upload file:" value="#{upload.file}"/>
+ <%-- code-sniplet-end id="file" --%>
+ <tc:button label="Submit" defaultCommand="true" action="#{upload.upload}"/>
+
+ <tc:cell spanX="2">
+ <tc:sheet var="entry" value="#{upload.list}">
+
+ <tc:column label="Name">
+ <tc:out value="#{entry.name}"/>
+ </tc:column>
+
+ <tc:column label="Type">
+ <tc:out value="#{entry.type}"/>
+ </tc:column>
+
+ <tc:column label="Size">
+ <tc:out value="#{entry.size}"/>
+ </tc:column>
+
+ </tc:sheet>
+ </tc:cell>
+
</tc:box>
</jsp:body>
</layout:overview>