KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > formbean > UploadFlashForm


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package dlog4j.formbean;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
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 /**
27  * 上传flash的表单对象
28  * @author Liudong
29  */

30 public class UploadFlashForm extends DlogActionForm {
31     
32     FormFile uploadFile = null;
33     String JavaDoc flashUrl = null;
34     String JavaDoc txtWidth;
35     String JavaDoc txtHeight;
36     boolean transparent;
37     boolean loop;
38     boolean play;
39     boolean menu;
40     /**
41      * 验证参数的有效性
42      */

43     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc req) {
44         ActionErrors aes = new ActionErrors();
45         try {
46             if(!StringUtils.isEmpty(txtWidth))
47                 Integer.parseInt(txtWidth);
48         }catch(Exception JavaDoc 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 JavaDoc 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 JavaDoc 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     /**
75      * @return
76      */

77     public String JavaDoc getFlashUrl() {
78         return flashUrl;
79     }
80
81     /**
82      * @return
83      */

84     public String JavaDoc getTxtHeight() {
85         return txtHeight;
86     }
87
88     /**
89      * @return
90      */

91     public String JavaDoc getTxtWidth() {
92         return txtWidth;
93     }
94
95     /**
96      * @param string
97      */

98     public void setFlashUrl(String JavaDoc string) {
99         flashUrl = string;
100     }
101
102     /**
103      * @param string
104      */

105     public void setTxtHeight(String JavaDoc string) {
106         txtHeight = string;
107     }
108
109     /**
110      * @param string
111      */

112     public void setTxtWidth(String JavaDoc string) {
113         txtWidth = string;
114     }
115
116     /**
117      * @return
118      */

119     public boolean isLoop() {
120         return loop;
121     }
122
123     /**
124      * @return
125      */

126     public boolean isMenu() {
127         return menu;
128     }
129
130     /**
131      * @return
132      */

133     public boolean isPlay() {
134         return play;
135     }
136
137     /**
138      * @return
139      */

140     public boolean isTransparent() {
141         return transparent;
142     }
143
144     /**
145      * @param b
146      */

147     public void setLoop(boolean b) {
148         loop = b;
149     }
150
151     /**
152      * @param b
153      */

154     public void setMenu(boolean b) {
155         menu = b;
156     }
157
158     /**
159      * @param b
160      */

161     public void setPlay(boolean b) {
162         play = b;
163     }
164
165     /**
166      * @param b
167      */

168     public void setTransparent(boolean b) {
169         transparent = b;
170     }
171
172 }
173
Popular Tags