1 20 21 package org.objectweb.jonas.webapp.jonasadmin.deploy; 22 import javax.servlet.http.HttpServletRequest ; 23 24 import org.apache.struts.action.ActionErrors; 25 import org.apache.struts.action.ActionForm; 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 41 public class UploadForm extends ActionForm { 42 43 46 private FormFile uploadedFile; 47 48 51 private boolean isDomain; 52 53 56 private boolean overwrite = false; 57 58 62 public boolean getIsDomain() { 63 return this.isDomain; 64 } 65 66 70 public void setIsDomain(boolean isDomain) { 71 this.isDomain = isDomain; 72 } 73 74 77 public FormFile getUploadedFile() { 78 return uploadedFile; 79 } 80 81 85 public void setUploadedFile(FormFile uploadedFile) { 86 this.uploadedFile = uploadedFile; 87 } 88 89 90 97 public ActionErrors validate( 98 ActionMapping mapping, 99 HttpServletRequest request) { 100 101 ActionErrors errors = null; 102 Boolean maxLengthExceeded = 104 (Boolean ) request.getAttribute( 105 MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED); 106 107 if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) { 108 errors = new ActionErrors(); 109 errors.add( 110 ActionMessages.GLOBAL_MESSAGE , 111 new ActionMessage("maxLengthExceeded")); 112 errors.add( 113 ActionMessages.GLOBAL_MESSAGE , 114 new ActionMessage("maxLengthExplanation")); 115 } 116 return errors; 117 118 } 119 120 123 public boolean isOverwrite() { 124 return overwrite; 125 } 126 127 128 132 public void setOverwrite(boolean overwrite) { 133 this.overwrite = overwrite; 134 } 135 } | Popular Tags |