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 2012/07/04 16:03:18 UTC

svn commit: r1357270 - in /myfaces/tobago/trunk/tobago-example: tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Upload.java tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Upload.java

Author: lofwyr
Date: Wed Jul  4 14:03:18 2012
New Revision: 1357270

URL: http://svn.apache.org/viewvc?rev=1357270&view=rev
Log:
demo

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Upload.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Upload.java

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Upload.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Upload.java?rev=1357270&r1=1357269&r2=1357270&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Upload.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Upload.java Wed Jul  4 14:03:18 2012
@@ -22,6 +22,8 @@ import org.apache.myfaces.tobago.example
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -34,6 +36,11 @@ public class Upload {
   private List<UploadItem> list = new ArrayList<UploadItem>();
 
   public String upload() {
+    if (file == null) {
+      FacesContext.getCurrentInstance().addMessage(
+          null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "No UploadItem found!", null));
+      return null;
+    }
     LOG.info("type=" + file.getContentType());
     LOG.info("size=" + file.get().length);
     String name = file.getName();

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Upload.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Upload.java?rev=1357270&r1=1357269&r2=1357270&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Upload.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Upload.java Wed Jul  4 14:03:18 2012
@@ -21,6 +21,9 @@ import org.apache.commons.fileupload.Fil
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
 public class Upload {
 
   private static final Logger LOG = LoggerFactory.getLogger(Upload.class);
@@ -28,6 +31,11 @@ public class Upload {
   private FileItem file;
 
   public String upload() {
+    if (file == null) {
+      FacesContext.getCurrentInstance().addMessage(
+          null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "No UploadItem found!", null));
+      return null;
+    }
     LOG.info("type=" + file.getContentType());
     LOG.info("size=" + file.get().length);
     LOG.info("name=" + file.getName());