001: /*
002: * This program is free software; you can redistribute it and/or modify
003: * it under the terms of the GNU General Public License as published by
004: * the Free Software Foundation; either version 2 of the License, or
005: * (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU Library General Public License for more details.
011: *
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package dlog4j.formbean;
017:
018: import javax.servlet.http.HttpServletRequest;
019:
020: import org.apache.commons.lang.StringUtils;
021: import org.apache.struts.action.ActionError;
022: import org.apache.struts.action.ActionErrors;
023: import org.apache.struts.action.ActionMapping;
024: import org.apache.struts.upload.FormFile;
025:
026: /**
027: * 上传flash的表单对象
028: * @author Liudong
029: */
030: public class UploadFlashForm extends DlogActionForm {
031:
032: FormFile uploadFile = null;
033: String flashUrl = null;
034: String txtWidth;
035: String txtHeight;
036: boolean transparent;
037: boolean loop;
038: boolean play;
039: boolean menu;
040:
041: /**
042: * 验证参数的有效性
043: */
044: public ActionErrors validate(ActionMapping mapping,
045: HttpServletRequest req) {
046: ActionErrors aes = new ActionErrors();
047: try {
048: if (!StringUtils.isEmpty(txtWidth))
049: Integer.parseInt(txtWidth);
050: } catch (Exception e) {
051: aes.add("txtWidth", new ActionError("illegal_input_value"));
052: }
053: try {
054: if (!StringUtils.isEmpty(txtHeight))
055: Integer.parseInt(txtHeight);
056: } catch (Exception e) {
057: aes
058: .add("txtHeight", new ActionError(
059: "illegal_input_value"));
060: }
061: if (uploadFile != null) {
062: if (uploadFile.getFileSize() > 1000000)
063: aes.add("uploadFile", new ActionError(
064: "upload_file_size_exceed"));
065: String fn = uploadFile.getFileName().toLowerCase();
066: if (!fn.endsWith(".swf"))
067: aes.add("uploadFile", new ActionError(
068: "upload_file_extend_noallow"));
069: if (uploadFile.getFileSize() <= 0)
070: aes.add("uploadFile", new ActionError(
071: "upload_file_illegal"));
072: }
073: return aes;
074: }
075:
076: public FormFile getUploadFile() {
077: return uploadFile;
078: }
079:
080: public void setUploadFile(FormFile uploadFile) {
081: this .uploadFile = uploadFile;
082: }
083:
084: /**
085: * @return
086: */
087: public String getFlashUrl() {
088: return flashUrl;
089: }
090:
091: /**
092: * @return
093: */
094: public String getTxtHeight() {
095: return txtHeight;
096: }
097:
098: /**
099: * @return
100: */
101: public String getTxtWidth() {
102: return txtWidth;
103: }
104:
105: /**
106: * @param string
107: */
108: public void setFlashUrl(String string) {
109: flashUrl = string;
110: }
111:
112: /**
113: * @param string
114: */
115: public void setTxtHeight(String string) {
116: txtHeight = string;
117: }
118:
119: /**
120: * @param string
121: */
122: public void setTxtWidth(String string) {
123: txtWidth = string;
124: }
125:
126: /**
127: * @return
128: */
129: public boolean isLoop() {
130: return loop;
131: }
132:
133: /**
134: * @return
135: */
136: public boolean isMenu() {
137: return menu;
138: }
139:
140: /**
141: * @return
142: */
143: public boolean isPlay() {
144: return play;
145: }
146:
147: /**
148: * @return
149: */
150: public boolean isTransparent() {
151: return transparent;
152: }
153:
154: /**
155: * @param b
156: */
157: public void setLoop(boolean b) {
158: loop = b;
159: }
160:
161: /**
162: * @param b
163: */
164: public void setMenu(boolean b) {
165: menu = b;
166: }
167:
168: /**
169: * @param b
170: */
171: public void setPlay(boolean b) {
172: play = b;
173: }
174:
175: /**
176: * @param b
177: */
178: public void setTransparent(boolean b) {
179: transparent = b;
180: }
181:
182: }
|