1 package org.appfuse.webapp.form; 2 3 import javax.servlet.http.HttpServletRequest ; 4 5 import org.apache.struts.action.ActionErrors; 6 import org.apache.struts.action.ActionMapping; 7 import org.apache.struts.action.ActionMessage; 8 import org.apache.struts.upload.FormFile; 9 import org.apache.struts.upload.MultipartRequestHandler; 10 11 12 22 public class UploadForm extends BaseForm { 23 private static final long serialVersionUID = 3257850969634190134L; 24 25 public static final String ERROR_PROPERTY_MAX_LENGTH_EXCEEDED = 26 "MaxLengthExceeded"; 27 28 29 protected String name; 30 31 32 protected FormFile file; 33 34 39 public String getName() { 40 return name; 41 } 42 43 48 public void setName(String name) { 49 this.name = name; 50 } 51 52 57 public FormFile getFile() { 58 return file; 59 } 60 61 66 public void setFile(FormFile file) { 67 this.file = file; 68 } 69 70 74 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 75 76 ActionErrors errors = super.validate(mapping, request); 77 78 Boolean maxLengthExceeded = 80 (Boolean ) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED); 81 if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) { 82 if (errors == null) { 83 errors = new ActionErrors(); 84 } 85 errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new ActionMessage("maxLengthExceeded")); 86 } 87 88 return errors; 89 } 90 } 91 | Popular Tags |