01: package com.technoetic.xplanner.forms;
02:
03: import java.util.List;
04: import java.util.ArrayList;
05: import javax.servlet.http.HttpServletRequest;
06:
07: import com.technoetic.xplanner.file.File;
08: import org.apache.commons.lang.StringUtils;
09: import org.apache.struts.action.*;
10: import org.apache.struts.upload.FormFile;
11:
12: /**
13: * User: Mateusz Prokopowicz
14: * Date: Jun 7, 2005
15: * Time: 12:02:31 PM
16: */
17: public class ImportForm extends AbstractEditorForm {
18: protected FormFile formFile;
19: protected String action = null;
20: protected List results = null;
21: private File file;
22: static final String NO_IMPORT_FILE_KEY = "import.status.no_import_file";
23:
24: public ActionErrors validate(ActionMapping mapping,
25: HttpServletRequest request) {
26: ActionErrors errors = new ActionErrors();
27: if (isSubmitted()) {
28: if (formFile == null
29: || StringUtils.isEmpty(formFile.getFileName())) {
30: errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
31: NO_IMPORT_FILE_KEY));
32: }
33:
34: }
35: return errors;
36: }
37:
38: public void reset(ActionMapping mapping, HttpServletRequest request) {
39: super .reset(mapping, request);
40: results = new ArrayList();
41: formFile = null;
42: action = null;
43: }
44:
45: public void setFormFile(FormFile formFile) {
46: this .formFile = formFile;
47: }
48:
49: public FormFile getFormFile() {
50: return formFile;
51: }
52:
53: public File getAttachedFile() {
54: return file;
55: }
56:
57: public void setFile(File file) {
58: this .file = file;
59: }
60:
61: public boolean isSubmitted() {
62: return action != null && !action.equals("")
63: && !action.equals("null");
64: }
65:
66: public String getAction() {
67: return action;
68: }
69:
70: public void setAction(String action) {
71: this .action = action;
72: }
73:
74: public List getResults() {
75: return results;
76: }
77:
78: public void setResults(List results) {
79: this.results = results;
80: }
81: }
|