1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.web.forms;
20
21 import java.util.HashMap;
22
23 import javax.servlet.http.HttpServletRequest;
24
25 import org.apache.struts.action.ActionErrors;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.action.ActionMessage;
28 import org.apache.struts.action.ActionMessages;
29 import org.apache.struts.validator.ValidatorForm;
30 import org.itracker.core.resources.ITrackerResources;
31 import org.itracker.web.actions.admin.configuration.EditCustomFieldActionUtil;
32 import org.itracker.web.util.LoginUtilities;
33
34
35
36
37
38
39
40 @SuppressWarnings("serial")
41 public class CustomFieldForm extends ValidatorForm {
42 String action = null;
43 Integer id = null;
44 Integer fieldType = null;
45 String required = null;
46 String dateFormat = null;
47 String sortOptionsByName = null;
48 String value = null;
49
50 HashMap<String, String> translations = new HashMap<String, String>();
51
52
53
54
55
56
57
58
59 @Override
60 public ActionErrors validate(ActionMapping mapping,
61 HttpServletRequest request) {
62 ActionErrors errors = super.validate(mapping, request);
63
64 if (null == getBaseTranslation() || "".equals(getBaseTranslation().trim())) {
65 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.validate.required",
66 ITrackerResources.getString("itracker.web.attr.baselocale", LoginUtilities.getCurrentLocale(request))));
67 }
68
69 EditCustomFieldActionUtil.setRequestEnv(request, this);
70 return errors;
71 }
72
73
74 @Override
75 public void reset(ActionMapping mapping, HttpServletRequest request) {
76 super.reset(mapping, request);
77 }
78
79 public String getAction() {
80 return action;
81 }
82
83 public void setAction(String action) {
84 this.action = action;
85 }
86
87 public String getDateFormat() {
88 return dateFormat;
89 }
90
91 public void setDateFormat(String dateFormat) {
92 this.dateFormat = dateFormat;
93 }
94
95 public Integer getFieldType() {
96 return fieldType;
97 }
98
99 public void setFieldType(Integer fieldType) {
100 this.fieldType = fieldType;
101 }
102
103 public Integer getId() {
104 return id;
105 }
106
107 public void setId(Integer id) {
108 this.id = id;
109 }
110
111 public String getRequired() {
112 return required;
113 }
114
115 public void setRequired(String required) {
116 this.required = required;
117 }
118
119 public String getSortOptionsByName() {
120 return sortOptionsByName;
121 }
122
123 public void setSortOptionsByName(String sortOptionsByName) {
124 this.sortOptionsByName = sortOptionsByName;
125 }
126
127 public HashMap<String, String> getTranslations() {
128 return translations;
129 }
130
131 public void setTranslations(HashMap<String, String> translations) {
132 this.translations = translations;
133 }
134
135 public String getValue() {
136 return value;
137 }
138
139 public void setValue(String value) {
140 this.value = value;
141 }
142
143
144
145
146
147 private String getBaseTranslation() {
148 return translations.get(ITrackerResources.BASE_LOCALE);
149 }
150
151
152 }