1 16 package com.blandware.atleap.webapp.form.core; 17 18 import com.blandware.atleap.webapp.form.BaseForm; 19 import com.blandware.atleap.webapp.util.core.WebappConstants; 20 import org.apache.struts.action.ActionErrors; 21 import org.apache.struts.action.ActionMapping; 22 import org.apache.struts.action.ActionMessage; 23 import org.apache.struts.upload.FormFile; 24 import org.apache.struts.upload.MultipartRequestHandler; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 38 public class UploadContentResourceForm extends BaseForm { 39 40 43 protected transient FormFile file; 44 45 50 public FormFile getFile() { 51 return file; 52 } 53 54 59 public void setFile(FormFile file) { 60 this.file = file; 61 } 62 63 67 public ActionErrors validate(ActionMapping mapping, 69 HttpServletRequest request) { 70 ActionErrors errors = null; 71 Boolean maxLengthExceeded = 73 (Boolean ) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED); 74 if ( (maxLengthExceeded != null) && (maxLengthExceeded.booleanValue()) ) { 75 errors = new ActionErrors(); 76 errors.add("contentResourceMaxLengthExceeded", 77 new ActionMessage("core.contentResource.errors.maxLengthExceeded")); 78 request.getSession().setAttribute(WebappConstants.ERROR_KEY, errors); 79 } 80 return errors; 81 } 82 83 } | Popular Tags |