diff --git a/source/java/org/alfresco/web/ui/common/component/UIOutputText.java b/source/java/org/alfresco/web/ui/common/component/UIOutputText.java
index 7cf2116bea..eb5eb999f1 100644
--- a/source/java/org/alfresco/web/ui/common/component/UIOutputText.java
+++ b/source/java/org/alfresco/web/ui/common/component/UIOutputText.java
@@ -18,10 +18,12 @@
package org.alfresco.web.ui.common.component;
import java.io.IOException;
+import java.net.URLEncoder;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
/**
* Component that simply renders text
@@ -30,6 +32,8 @@ import javax.faces.context.ResponseWriter;
*/
public class UIOutputText extends UIOutput
{
+ private Boolean encodeForJavaScript = null;
+
/**
* Default constructor
*/
@@ -45,6 +49,40 @@ public class UIOutputText extends UIOutput
{
return "org.alfresco.faces.OutputText";
}
+
+ /**
+ * Sets whether the text should be encoded for JavaScript consumption
+ *
+ * @param encodeForJavaScript true to escape text
+ */
+ public void setEncodeForJavaScript(boolean encodeForJavaScript)
+ {
+ this.encodeForJavaScript = Boolean.valueOf(encodeForJavaScript);
+ }
+
+ /**
+ * Returns whether the text is going to be encoded or not
+ *
+ * @return true if the text is going to be encoded
+ */
+ public boolean isEncodeForJavaScript()
+ {
+ if (this.encodeForJavaScript == null)
+ {
+ ValueBinding vb = getValueBinding("encodeForJavaScript");
+ if (vb != null)
+ {
+ this.encodeForJavaScript = (Boolean)vb.getValue(getFacesContext());
+ }
+
+ if (this.encodeForJavaScript == null)
+ {
+ this.encodeForJavaScript = Boolean.FALSE;
+ }
+ }
+
+ return this.encodeForJavaScript.booleanValue();
+ }
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
@@ -57,6 +95,18 @@ public class UIOutputText extends UIOutput
}
ResponseWriter out = context.getResponseWriter();
- out.write((String)getValue());
+
+ String output = null;
+
+ if (isEncodeForJavaScript())
+ {
+ output = URLEncoder.encode((String)getValue(), "UTF-8").replace('+', ' ');
+ }
+ else
+ {
+ output = (String)getValue();
+ }
+
+ out.write(output);
}
}
diff --git a/source/java/org/alfresco/web/ui/common/tag/OutputTextTag.java b/source/java/org/alfresco/web/ui/common/tag/OutputTextTag.java
index ad217b6342..147e5698ba 100644
--- a/source/java/org/alfresco/web/ui/common/tag/OutputTextTag.java
+++ b/source/java/org/alfresco/web/ui/common/tag/OutputTextTag.java
@@ -26,6 +26,7 @@ import javax.faces.component.UIComponent;
public class OutputTextTag extends HtmlComponentTag
{
private String value;
+ private String encodeForJavaScript;
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
@@ -51,6 +52,7 @@ public class OutputTextTag extends HtmlComponentTag
{
super.setProperties(component);
setStringProperty(component, "value", this.value);
+ setBooleanProperty(component, "encodeForJavaScript", this.encodeForJavaScript);
}
/**
@@ -60,6 +62,7 @@ public class OutputTextTag extends HtmlComponentTag
{
super.release();
this.value = null;
+ this.encodeForJavaScript = null;
}
/**
@@ -71,4 +74,14 @@ public class OutputTextTag extends HtmlComponentTag
{
this.value = value;
}
+
+ /**
+ * Set the encodeForJavaScript flag
+ *
+ * @param encodeForJavaScript true to encode the text for use in JavaScript
+ */
+ public void setEncodeForJavaScript(String encodeForJavaScript)
+ {
+ this.encodeForJavaScript = encodeForJavaScript;
+ }
}
diff --git a/source/web/WEB-INF/alfresco.tld b/source/web/WEB-INF/alfresco.tld
index 36166f665d..f32dac1fed 100644
--- a/source/web/WEB-INF/alfresco.tld
+++ b/source/web/WEB-INF/alfresco.tld
@@ -1627,6 +1627,12 @@
true
true
+
+
+ encodeForJavaScript
+ false
+ true
+
diff --git a/source/web/jsp/wizard/new-rule/condition.jsp b/source/web/jsp/wizard/new-rule/condition.jsp
index 5685d29984..bf17c14538 100644
--- a/source/web/jsp/wizard/new-rule/condition.jsp
+++ b/source/web/jsp/wizard/new-rule/condition.jsp
@@ -245,7 +245,7 @@
-