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