1 18 19 package org.apache.struts.webapp.upload; 20 21 import javax.servlet.http.HttpServletRequest ; 22 23 import org.apache.struts.action.*; 24 import org.apache.struts.upload.FormFile; 25 import org.apache.struts.upload.MultipartRequestHandler; 26 27 36 public class UploadForm extends ActionForm { 37 38 41 protected String theText; 42 43 46 protected String queryParam; 47 48 51 protected boolean writeFile; 52 53 56 protected FormFile theFile; 57 58 61 protected String filePath; 62 63 66 public String getTheText() { 67 return theText; 68 } 69 70 73 public void setTheText(String theText) { 74 this.theText = theText; 75 } 76 77 80 public String getQueryParam() { 81 return queryParam; 82 } 83 84 87 public void setQueryParam(String queryParam) { 88 this.queryParam = queryParam; 89 } 90 91 94 public FormFile getTheFile() { 95 return theFile; 96 } 97 98 101 public void setTheFile(FormFile theFile) { 102 this.theFile = theFile; 103 } 104 105 108 public void setWriteFile(boolean writeFile) { 109 this.writeFile = writeFile; 110 } 111 112 115 public boolean getWriteFile() { 116 return writeFile; 117 } 118 119 122 public void setFilePath(String filePath) { 123 this.filePath = filePath; 124 } 125 126 129 public String getFilePath() { 130 return filePath; 131 } 132 133 public void reset() { 134 writeFile = false; 135 } 136 137 141 public ActionErrors validate( 142 ActionMapping mapping, 143 HttpServletRequest request) { 144 145 ActionErrors errors = null; 146 Boolean maxLengthExceeded = 148 (Boolean ) request.getAttribute( 149 MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED); 150 151 if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) { 152 errors = new ActionErrors(); 153 errors.add( 154 ActionMessages.GLOBAL_MESSAGE , 155 new ActionMessage("maxLengthExceeded")); 156 errors.add( 157 ActionMessages.GLOBAL_MESSAGE , 158 new ActionMessage("maxLengthExplanation")); 159 } 160 return errors; 161 162 } 163 } 164 | Popular Tags |