1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.field;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
22 import org.kuali.rice.krad.datadictionary.validator.Validator;
23 import org.kuali.rice.krad.uif.UifConstants;
24 import org.kuali.rice.krad.uif.element.Link;
25 import org.kuali.rice.krad.uif.util.LifecycleElement;
26 import org.kuali.rice.krad.uif.widget.LightBox;
27
28
29
30
31
32
33 @BeanTag(name = "linkField", parent = "Uif-LinkField")
34 public class LinkField extends FieldBase {
35 private static final long serialVersionUID = -1908504471910271148L;
36
37 private Link link;
38
39 private String sortAs;
40
41 public LinkField() {
42 super();
43 }
44
45
46
47
48
49
50
51
52
53
54 @Override
55 public void performInitialization(Object model) {
56 super.performInitialization(model);
57
58 if (StringUtils.isBlank(getLinkText())) {
59 setLinkText(this.getLabel());
60 }
61 }
62
63
64
65
66
67
68
69
70 @Override
71 public void performFinalize(Object model, LifecycleElement parent) {
72 super.performFinalize(model, parent);
73
74
75 if (this.getFieldLabel() != null && this.getLink() != null && StringUtils.isNotBlank(this.getLink().getId())) {
76 this.getFieldLabel().setLabelForComponentId(this.getLink().getId());
77 }
78 }
79
80
81
82
83
84
85 @BeanTagAttribute(type= BeanTagAttribute.AttributeType.DIRECTORBYTYPE)
86 public Link getLink() {
87 return link;
88 }
89
90
91
92
93
94
95 public void setLink(Link link) {
96 this.link = link;
97 }
98
99
100
101
102
103
104 @BeanTagAttribute
105 public String getLinkText() {
106 return link.getLinkText();
107 }
108
109
110
111
112
113
114 public void setLinkText(String linkLabel) {
115 link.setLinkText(linkLabel);
116 }
117
118
119
120
121
122
123
124
125
126 @BeanTagAttribute
127 public String getLinkDialogId() {
128 return link.getLinkDialogId();
129 }
130
131
132
133
134 public void setLinkDialogId(String linkDialogId) {
135 link.setLinkDialogId(linkDialogId);
136 }
137
138
139
140
141
142
143
144
145
146
147 @BeanTagAttribute
148 public boolean isOpenInDialog() {
149 return link.isOpenInDialog();
150 }
151
152
153
154
155 public void setOpenInDialog(boolean openInDialog) {
156 link.setOpenInDialog(openInDialog);
157 }
158
159
160
161
162
163
164
165 @BeanTagAttribute
166 public String getTarget() {
167 return link.getTarget();
168 }
169
170
171
172
173
174
175 public void setTarget(String target) {
176 link.setTarget(target);
177 }
178
179
180
181
182
183
184 @BeanTagAttribute
185 public String getHref() {
186 return link.getHref();
187 }
188
189
190
191
192
193
194 public void setHref(String hrefText) {
195 link.setHref(hrefText);
196 }
197
198 @BeanTagAttribute(name = "sortAs")
199 public String getSortAs() {
200 return sortAs;
201 }
202
203 public void setSortAs(String sortAs) {
204 if (!(sortAs.equals(UifConstants.TableToolsValues.DATE) || sortAs.equals(UifConstants.TableToolsValues.NUMERIC) || sortAs.equals(UifConstants.TableToolsValues.STRING))) {
205 throw new IllegalArgumentException("invalid sortAs value of " + sortAs + ", allowed: " + UifConstants.TableToolsValues.DATE + "|" + UifConstants.TableToolsValues.NUMERIC + "|" + UifConstants.TableToolsValues.STRING);
206 }
207 this.sortAs = sortAs;
208 }
209
210
211
212
213 @Override
214 public void completeValidation(ValidationTrace tracer) {
215 tracer.addBean(this);
216
217
218 if (getLink() == null) {
219 if (Validator.checkExpressions(this, "link")) {
220 String currentValues[] = {"link = " + getLink()};
221 tracer.createError("Link should be set", currentValues);
222 }
223 }
224
225
226 if (getLabel() == null) {
227 if (Validator.checkExpressions(this, "label")) {
228 String currentValues[] = {"label =" + getLabel(), "link =" + getLink()};
229 tracer.createWarning("Label is null, link should be used instead", currentValues);
230 }
231 }
232
233 super.completeValidation(tracer.getCopy());
234 }
235 }