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.util.LoginUtilities;
32
33
34
35
36
37
38
39 public class CustomFieldValueForm extends ValidatorForm {
40
41
42
43 private static final long serialVersionUID = 1L;
44 private String action;
45
46 private Integer id;
47
48 private String value;
49 private Integer sortOrder;
50
51 private HashMap<String, String> translations = new HashMap<String, String>();
52
53
54
55 public String getAction() {
56 return action;
57 }
58
59 public void setAction(String action) {
60 this.action = action;
61 }
62
63 public Integer getId() {
64 return id;
65 }
66
67 public void setId(Integer id) {
68 this.id = id;
69 }
70
71
72 public HashMap<String, String> getTranslations() {
73 return translations;
74 }
75
76
77 public void setTranslations(HashMap<String, String> translations) {
78 this.translations = translations;
79 }
80
81
82
83
84
85 private String getBaseTranslation() {
86 return translations.get(ITrackerResources.BASE_LOCALE);
87 }
88
89 public String getValue() {
90 return value;
91 }
92
93 public void setValue(String value) {
94 this.value = value;
95 }
96
97 public void reset(ActionMapping mapping, HttpServletRequest request) {
98
99 }
100
101 public void setSortOrder(Integer sortOrder) {
102 this.sortOrder = sortOrder;
103 }
104
105 public Integer getSortOrder() {
106 return sortOrder;
107 }
108
109 public ActionErrors validate(ActionMapping mapping,
110 HttpServletRequest request) {
111 ActionErrors errors = super.validate(mapping, request);
112
113
114 if (null == getBaseTranslation() || "".equals(getBaseTranslation().trim())) {
115 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.validate.required",
116 ITrackerResources.getString("itracker.web.attr.baselocale", LoginUtilities.getCurrentLocale(request))));
117 }
118 return errors;
119 }
120
121
122 }