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