1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.uif.container; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.api.config.property.ConfigurationService; |
20 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
21 | |
import org.kuali.rice.krad.uif.component.Component; |
22 | |
import org.kuali.rice.krad.uif.view.View; |
23 | |
import org.kuali.rice.krad.uif.widget.Growls; |
24 | |
import org.kuali.rice.krad.util.ErrorMessage; |
25 | |
import org.kuali.rice.krad.util.GlobalVariables; |
26 | |
import org.kuali.rice.krad.util.MessageMap; |
27 | |
import org.springframework.util.AutoPopulatingList; |
28 | |
|
29 | |
import java.text.MessageFormat; |
30 | |
import java.util.List; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class PageGroup extends Group { |
36 | |
private static final long serialVersionUID = 7571981300587270274L; |
37 | |
|
38 | |
private boolean autoFocus; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
@Override |
48 | |
public void performFinalize(View view, Object model, Component parent) { |
49 | 0 | super.performFinalize(view, model, parent); |
50 | |
|
51 | 0 | String prefixScript = ""; |
52 | 0 | if (this.getOnDocumentReadyScript() != null) { |
53 | 0 | prefixScript = this.getOnDocumentReadyScript(); |
54 | |
} |
55 | |
|
56 | |
|
57 | |
|
58 | 0 | String growlScript = ""; |
59 | 0 | if (view.isGrowlMessagingEnabled()) { |
60 | 0 | Growls gw = view.getGrowls(); |
61 | |
|
62 | |
|
63 | 0 | if (!gw.getComponentOptions().isEmpty()) { |
64 | 0 | growlScript = "setGrowlDefaults(" + gw.getComponentOptionsJSString() + ");"; |
65 | |
} |
66 | |
|
67 | 0 | ConfigurationService configService = KRADServiceLocator.getKualiConfigurationService(); |
68 | 0 | MessageMap messageMap = GlobalVariables.getMessageMap(); |
69 | 0 | if (messageMap.hasErrors()) { |
70 | 0 | String message = configService.getPropertyValueAsString("growl.hasErrors"); |
71 | 0 | if (StringUtils.isNotBlank(message)) { |
72 | 0 | growlScript = |
73 | |
growlScript + "showGrowl('" + message + "', '" + configService.getPropertyValueAsString( |
74 | |
"general.error") + "', 'errorGrowl');"; |
75 | |
} |
76 | |
} |
77 | |
|
78 | 0 | if (messageMap.hasWarnings()) { |
79 | 0 | String message = configService.getPropertyValueAsString("growl.hasWarnings"); |
80 | 0 | if (StringUtils.isNotBlank(message)) { |
81 | 0 | growlScript = |
82 | |
growlScript + "showGrowl('" + message + "', '" + configService.getPropertyValueAsString( |
83 | |
"general.warning") + "', 'warningGrowl');"; |
84 | |
} |
85 | |
} |
86 | |
|
87 | 0 | if (messageMap.hasInfo()) { |
88 | 0 | List<String> properties = messageMap.getPropertiesWithInfo(); |
89 | 0 | String message = ""; |
90 | 0 | for (String property : properties) { |
91 | 0 | List<AutoPopulatingList<ErrorMessage>> lists = messageMap.getInfoMessagesForProperty(property, |
92 | |
true); |
93 | 0 | for (List<ErrorMessage> errorList : lists) { |
94 | 0 | if (errorList != null) { |
95 | 0 | for (ErrorMessage e : errorList) { |
96 | 0 | if (StringUtils.isBlank(message)) { |
97 | 0 | message = configService.getPropertyValueAsString(e.getErrorKey()); |
98 | |
} else { |
99 | 0 | message = message + "<br/>" + configService.getPropertyValueAsString( |
100 | |
e.getErrorKey()); |
101 | |
} |
102 | 0 | if (e.getMessageParameters() != null) { |
103 | 0 | message = message.replace("'", "''"); |
104 | 0 | message = MessageFormat.format(message, (Object[]) e.getMessageParameters()); |
105 | |
} |
106 | |
} |
107 | |
} |
108 | |
} |
109 | 0 | } |
110 | |
|
111 | 0 | if (StringUtils.isNotBlank(message)) { |
112 | 0 | growlScript = |
113 | |
growlScript + "showGrowl('" + message + "', '" + configService.getPropertyValueAsString( |
114 | |
"general.info") + "', 'infoGrowl');"; |
115 | |
} |
116 | |
} |
117 | |
} |
118 | |
|
119 | 0 | this.setOnDocumentReadyScript(prefixScript + "\nsetupValidator();" + growlScript); |
120 | 0 | } |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public boolean isAutoFocus() { |
131 | 0 | return this.autoFocus; |
132 | |
} |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public void setAutoFocus(boolean autoFocus) { |
138 | 0 | this.autoFocus = autoFocus; |
139 | 0 | } |
140 | |
|
141 | |
} |