1 16 package dlog4j.formbean; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 import org.apache.commons.lang.StringUtils; 21 import org.apache.struts.action.ActionError; 22 import org.apache.struts.action.ActionErrors; 23 import org.apache.struts.action.ActionMapping; 24 import org.apache.struts.upload.FormFile; 25 26 30 public class UploadFlashForm extends DlogActionForm { 31 32 FormFile uploadFile = null; 33 String flashUrl = null; 34 String txtWidth; 35 String txtHeight; 36 boolean transparent; 37 boolean loop; 38 boolean play; 39 boolean menu; 40 43 public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) { 44 ActionErrors aes = new ActionErrors(); 45 try { 46 if(!StringUtils.isEmpty(txtWidth)) 47 Integer.parseInt(txtWidth); 48 }catch(Exception e) { 49 aes.add("txtWidth",new ActionError("illegal_input_value")); 50 } 51 try { 52 if(!StringUtils.isEmpty(txtHeight)) 53 Integer.parseInt(txtHeight); 54 }catch(Exception e) { 55 aes.add("txtHeight",new ActionError("illegal_input_value")); 56 } 57 if(uploadFile!=null){ 58 if(uploadFile.getFileSize()>1000000) 59 aes.add("uploadFile",new ActionError("upload_file_size_exceed")); 60 String fn = uploadFile.getFileName().toLowerCase(); 61 if(!fn.endsWith(".swf")) 62 aes.add("uploadFile",new ActionError("upload_file_extend_noallow")); 63 if(uploadFile.getFileSize()<=0) 64 aes.add("uploadFile",new ActionError("upload_file_illegal")); 65 } 66 return aes; 67 } 68 public FormFile getUploadFile() { 69 return uploadFile; 70 } 71 public void setUploadFile(FormFile uploadFile) { 72 this.uploadFile = uploadFile; 73 } 74 77 public String getFlashUrl() { 78 return flashUrl; 79 } 80 81 84 public String getTxtHeight() { 85 return txtHeight; 86 } 87 88 91 public String getTxtWidth() { 92 return txtWidth; 93 } 94 95 98 public void setFlashUrl(String string) { 99 flashUrl = string; 100 } 101 102 105 public void setTxtHeight(String string) { 106 txtHeight = string; 107 } 108 109 112 public void setTxtWidth(String string) { 113 txtWidth = string; 114 } 115 116 119 public boolean isLoop() { 120 return loop; 121 } 122 123 126 public boolean isMenu() { 127 return menu; 128 } 129 130 133 public boolean isPlay() { 134 return play; 135 } 136 137 140 public boolean isTransparent() { 141 return transparent; 142 } 143 144 147 public void setLoop(boolean b) { 148 loop = b; 149 } 150 151 154 public void setMenu(boolean b) { 155 menu = b; 156 } 157 158 161 public void setPlay(boolean b) { 162 play = b; 163 } 164 165 168 public void setTransparent(boolean b) { 169 transparent = b; 170 } 171 172 } 173 | Popular Tags |