1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.element;
17
18 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
21 import org.kuali.rice.krad.uif.UifConstants;
22 import org.kuali.rice.krad.uif.component.Component;
23 import org.kuali.rice.krad.uif.util.ScriptUtils;
24 import org.kuali.rice.krad.uif.view.View;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29
30
31
32
33
34 @BeanTag(name = "fieldValidationMessages", parent = "Uif-FieldValidationMessages")
35 public class FieldValidationMessages extends ValidationMessages {
36
37 private boolean useTooltip;
38 private boolean showIcons;
39
40
41
42
43
44
45
46 @Override
47 public void generateMessages(View view, Object model, Component parent) {
48 super.generateMessages(view, model, parent);
49
50 boolean hasMessages = false;
51 if (!this.getErrors().isEmpty() || !this.getWarnings().isEmpty() || !this.getInfos().isEmpty()) {
52 hasMessages = true;
53 }
54 HashMap<String, Object> validationMessagesDataAttributes = new HashMap<String, Object>();
55
56 Map<String, String> dataDefaults =
57 (Map<String, String>) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryBean(
58 "Uif-FieldValidationMessages-DataDefaults"));
59
60
61 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "displayMessages",
62 this.isDisplayMessages());
63
64
65 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "useTooltip", useTooltip);
66 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "messagingEnabled",
67 this.isDisplayMessages());
68 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "hasOwnMessages",
69 hasMessages);
70 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "showIcons", showIcons);
71
72
73 if (hasMessages) {
74 parent.addDataAttribute(UifConstants.DataAttributes.HAS_MESSAGES, Boolean.toString(hasMessages));
75 }
76
77
78 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "serverErrors",
79 ScriptUtils.escapeHtml(this.getErrors()));
80 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "serverWarnings",
81 ScriptUtils.escapeHtml(this.getWarnings()));
82 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "serverInfo",
83 ScriptUtils.escapeHtml(this.getInfos()));
84
85 if (!validationMessagesDataAttributes.isEmpty()) {
86 parent.addScriptDataAttribute(UifConstants.DataAttributes.VALIDATION_MESSAGES, ScriptUtils.translateValue(
87 validationMessagesDataAttributes));
88 }
89 }
90
91
92
93
94
95
96
97 @BeanTagAttribute
98 public boolean isUseTooltip() {
99 return useTooltip;
100 }
101
102
103
104
105
106
107 public void setUseTooltip(boolean useTooltip) {
108 this.useTooltip = useTooltip;
109 }
110
111
112
113
114
115
116 @BeanTagAttribute
117 public boolean isShowIcons() {
118 return showIcons;
119 }
120
121
122
123
124
125
126 public void setShowIcons(boolean showIcons) {
127 this.showIcons = showIcons;
128 }
129 }