1 5 package com.opensymphony.webwork.sandbox; 6 7 import com.opensymphony.xwork.ActionSupport; 8 9 import java.io.File ; 10 11 14 public class FileUploadTestAction extends ActionSupport { 15 16 private File uploadedItem; 17 private String uploadedItemContentType; 18 private String uploadedItemFileName; 19 20 22 public void setUploadedItem(File uploadedItem) { 23 this.uploadedItem = uploadedItem; 24 } 25 26 public void setUploadedItemContentType(String uploadedItemContentType) { 27 this.uploadedItemContentType = uploadedItemContentType; 28 } 29 30 public void setUploadedItemFileName(String uploadedItemFileName) { 31 this.uploadedItemFileName = uploadedItemFileName; 32 } 33 34 36 public String execute() throws Exception { 37 return SUCCESS; 38 } 39 40 public String attemptUpload() throws Exception { 41 if (uploadedItem != null) { 42 addActionMessage("Uploaded File: " + uploadedItemFileName + 43 ", with a contentType of " + uploadedItemContentType); 44 } else { 45 addActionError("File upload unsuccessful. Please verify that the file is allowed and within the size limits."); 46 } 47 48 return SUCCESS; 49 } 50 } 51 | Popular Tags |