1 19 20 package com.sslexplorer.vfs.forms; 21 22 import javax.servlet.ServletRequest ; 23 import javax.servlet.http.HttpServletRequest ; 24 25 import org.apache.struts.action.ActionErrors; 26 import org.apache.struts.action.ActionMapping; 27 import org.apache.struts.action.ActionMessage; 28 import org.apache.struts.action.ActionMessages; 29 import org.apache.struts.upload.FormFile; 30 import org.apache.struts.upload.MultipartRequestHandler; 31 32 35 public class UploadForm extends AbstractUploadForm { 36 37 private FormFile uploadFile; 38 39 43 public ActionErrors validate( 44 ActionMapping mapping, 45 HttpServletRequest request) { 46 47 ActionErrors errors = null; 48 Boolean maxLengthExceeded = 50 (Boolean ) request.getAttribute( 51 MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED); 52 53 if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) { 54 errors = new ActionErrors(); 55 errors.add( 56 ActionMessages.GLOBAL_MESSAGE , 57 new ActionMessage("uploadFile.error.maxLengthExceeded")); 58 } 59 return errors; 60 61 } 62 63 66 public void setUploadFile(FormFile uploadFile) { 67 this.uploadFile = uploadFile; 68 } 69 70 73 public FormFile getUploadFile() { 74 return uploadFile; 75 } 76 77 80 public void reset(ActionMapping mapping, ServletRequest request) { 81 super.reset(mapping, request); 82 uploadFile = null; 83 } 84 } 85 | Popular Tags |