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 @BeanTag(name = "fieldValidationMessages-bean", parent = "Uif-FieldValidationMessages")
33 public class FieldValidationMessages extends ValidationMessages {
34
35 private boolean useTooltip;
36 private boolean showIcons;
37
38 @Override
39
40
41
42
43
44
45 public void generateMessages(boolean reset, View view, Object model, Component parent) {
46 super.generateMessages(reset, view, model, parent);
47 boolean hasMessages = false;
48 if (!this.getErrors().isEmpty() || !this.getWarnings().isEmpty() || !this.getInfos().isEmpty()) {
49 hasMessages = true;
50 }
51 HashMap<String, Object> validationMessagesDataAttributes = new HashMap<String, Object>();
52
53 Map<String, String> dataDefaults =
54 (Map<String, String>) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryObject(
55 "Uif-FieldValidationMessages-DataDefaults"));
56
57
58 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "displayMessages",
59 this.isDisplayMessages());
60
61
62 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "useTooltip", useTooltip);
63 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "messagingEnabled",
64 this.isDisplayMessages());
65 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "hasOwnMessages",
66 hasMessages);
67 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "showIcons", showIcons);
68
69
70 if (hasMessages) {
71 parent.addDataAttribute(UifConstants.DataAttributes.HAS_MESSAGES, Boolean.toString(hasMessages));
72 }
73
74
75 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "serverErrors",
76 ScriptUtils.escapeHtml(this.getErrors()));
77 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "serverWarnings",
78 ScriptUtils.escapeHtml(this.getWarnings()));
79 this.addValidationDataSettingsValue(validationMessagesDataAttributes, dataDefaults, "serverInfo",
80 ScriptUtils.escapeHtml(this.getInfos()));
81
82 if (!validationMessagesDataAttributes.isEmpty()) {
83 parent.addDataAttribute(UifConstants.DataAttributes.VALIDATION_MESSAGES, ScriptUtils.translateValue(
84 validationMessagesDataAttributes));
85 }
86 }
87
88
89
90
91
92
93
94 @BeanTagAttribute(name = "useTooltip")
95 public boolean isUseTooltip() {
96 return useTooltip;
97 }
98
99
100
101
102
103
104 public void setUseTooltip(boolean useTooltip) {
105 this.useTooltip = useTooltip;
106 }
107
108
109
110
111
112
113 @BeanTagAttribute(name = "showIcons")
114 public boolean isShowIcons() {
115 return showIcons;
116 }
117
118
119
120
121
122
123 public void setShowIcons(boolean showIcons) {
124 this.showIcons = showIcons;
125 }
126
127
128
129
130 @Override
131 protected <T> void copyProperties(T component) {
132 super.copyProperties(component);
133 FieldValidationMessages fieldValidationMessagesCopy = (FieldValidationMessages) component;
134 fieldValidationMessagesCopy.setUseTooltip(this.useTooltip);
135 fieldValidationMessagesCopy.setShowIcons(this.showIcons);
136 }
137 }