mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix for AWC-394
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2333 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -1627,6 +1627,12 @@
|
||||
<required>true</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
|
||||
<attribute>
|
||||
<name>encodeForJavaScript</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
<tag>
|
||||
|
@@ -245,7 +245,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script language="JavaScript1.2">
|
||||
<script language="JavaScript1.5">
|
||||
function itemSelected(inputField)
|
||||
{
|
||||
if (inputField.selectedIndex == 0)
|
||||
@@ -259,19 +259,19 @@
|
||||
|
||||
// also check to see if the 'no-condition' option has been selected, if it has, change
|
||||
// the explanation text and the button label
|
||||
var short_text = "<a:outputText value='#{msg.click_add_to_list}'/>";
|
||||
var long_text = "<a:outputText value='#{msg.click_set_and_add}'/>";
|
||||
var short_label = "<a:outputText value='#{msg.add_to_list_button}'/>";
|
||||
var long_label = "<a:outputText value='#{msg.set_and_add_button}'/>";
|
||||
var short_text = "<a:outputText value='#{msg.click_add_to_list}' />";
|
||||
var long_text = "<a:outputText value='#{msg.click_set_and_add}' />";
|
||||
var short_label = "<a:outputText value='#{msg.add_to_list_button}' encodeForJavaScript='true' />";
|
||||
var long_label = "<a:outputText value='#{msg.set_and_add_button}' encodeForJavaScript='true' />";
|
||||
|
||||
if (inputField.value == "no-condition")
|
||||
{
|
||||
document.getElementById("new-rule-condition:set-add-button").value = short_label;
|
||||
document.getElementById("new-rule-condition:set-add-button").value = decodeURI(short_label);
|
||||
document.getElementById("new-rule-condition:instruction-text").innerHTML = short_text;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("new-rule-condition:set-add-button").value = long_label;
|
||||
document.getElementById("new-rule-condition:set-add-button").value = decodeURI(long_label);
|
||||
document.getElementById("new-rule-condition:instruction-text").innerHTML = long_text;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user