1 25 29 package org.jresearch.gossip.forms; 30 31 import javax.servlet.http.HttpServletRequest ; 32 33 import org.apache.struts.action.ActionError; 34 import org.apache.struts.action.ActionErrors; 35 import org.apache.struts.action.ActionMapping; 36 import org.apache.struts.upload.FormFile; 37 import org.apache.struts.upload.MultipartRequestHandler; 38 import org.apache.struts.validator.ValidatorForm; 39 40 44 public class SaveAvatarForm extends ValidatorForm { 45 private String url; 46 47 50 public String getUrl() { 51 return url; 52 } 53 54 58 public void setUrl(String url) { 59 this.url = url; 60 } 61 62 private FormFile file; 63 64 67 public FormFile getFile() { 68 return file; 69 } 70 71 75 public void setFile(FormFile file) { 76 this.file = file; 77 } 78 79 84 public ActionErrors validate(ActionMapping mapping, 85 HttpServletRequest request) { 86 ActionErrors errors = super.validate(mapping, request); 87 Boolean maxLengthExceeded = (Boolean ) request 89 .getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED); 90 if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) { 91 errors = new ActionErrors(); 92 errors.add("maxLengthExceeded", new ActionError( 93 "error.maxLengthExceeded", "maxLengthExceeded")); 94 } 95 return errors; 96 97 } 98 } 99 | Popular Tags |