Author: sergeyhalipov
Date: 2008-03-19 12:36:33 -0400 (Wed, 19 Mar 2008)
New Revision: 6962
Modified:
trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java
Log:
http://jira.jboss.com/jira/browse/RF-2464
Modified: trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java
===================================================================
---
trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java 2008-03-19
16:25:13 UTC (rev 6961)
+++
trunk/ui/modal-panel/src/main/java/org/richfaces/component/UIModalPanel.java 2008-03-19
16:36:33 UTC (rev 6962)
@@ -130,11 +130,16 @@
}
public Object getVisualOptions() {
+ if (null != this.visualOptions) {
+ return this.visualOptions;
+ }
+
ValueExpression ve = getValueExpression("visualOptions");
if (null != ve) {
try {
Object value = ve.getValue(getFacesContext().getELContext());
- return prepareVisualOptions(value);
+ this.visualOptions = prepareVisualOptions(value);
+ return this.visualOptions;
} catch (ELException e) {
throw new FacesException(e);
}
@@ -182,26 +187,23 @@
protected Map<String, String> prepareVisualOptions(Object value) {
if (null == value) {
- if (null == this.visualOptions) {
- this.visualOptions = new HashMap<String, String>();
+ return new HashMap<String, String>();
+ } else if (value instanceof Map) {
+ return (Map<String, String>) value;
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (!s.startsWith("{")) {
+ s = "{" + s + "}";
}
- return this.visualOptions;
- } else if (value instanceof Map) {
- return (Map<String, String>) value;
- } else if (value instanceof String) {
- String s = (String) value;
- if (!s.startsWith("{")) {
- s = "{" + s + "}";
- }
- try {
- return new JSONMap(s);
- } catch (JSONException e) {
- throw new FacesException(e);
- }
- } else {
- throw new FacesException("Attribute visualOptions of component [" +
- this.getClientId(getFacesContext()) + "] must be instance of Map or String,
but its type is " +
- value.getClass().getSimpleName());
- }
+ try {
+ return new HashMap<String, String>(new JSONMap(s));
+ } catch (JSONException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ throw new FacesException("Attribute visualOptions of component [" +
+ this.getClientId(getFacesContext()) + "] must be instance of Map or String, but
its type is " +
+ value.getClass().getSimpleName());
+ }
}
}