]
Christophe Porté commented on RF-12764:
---------------------------------------
This issue affects also the current 4.3.7 version, and is quite critical, as when the
failing javascript is added to the current page, major part of the page fails and become
unusable (no more ajax calls)
rich:select - javascript error when using myfaces with french locale
--------------------------------------------------------------------
Key: RF-12764
URL:
https://issues.jboss.org/browse/RF-12764
Project: RichFaces
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.3.0.CR2
Reporter: Dupont Dupont
Labels: patch_proposed
Fix For: 5-Tracking
Using RF 4.3.0.CR2, using rich:select with french locale on Myfaces produces the
following javascript error :
{code}
Uncaught SyntaxError: Unexpected identifier.
{code}
It appears when javax.faces.component.UISelectOne.INVALID error message has a value
containing a single quote.
To reproduce it, just add the following line in your jsf messages properties :
{code}
javax.faces.component.UISelectOne.INVALID = {0} : Erreur de validation : la valeur
n''est pas valide.
{code}
And add a rich:select in your JSF page.
We end up with the javascript :
{code}
RichFaces.csv.addMessage({ 'UISELECTONE_INVALID': {detail:'{0} : Erreur de
validation : la valeur n'est pas valide.',summary:'{0} : Erreur de validation
: la valeur n'est pas valide.',severity:2} });
{code}
This error impacts users of Websphere 8 (tested on 8.0.0.3) with french locale (myfaces
provides a default message containing simple quotes).
Resolved locally by modifying AddCSVMessageScript#appendcript
But perhaps I've missed some side effects.
{code:java}
@Override
public void appendScript(Appendable target) throws IOException {
String summary = facesMessage.getSummary();
String detail = facesMessage.getDetail();
int severity = facesMessage.getSeverity().getOrdinal();
StringBuilder builder = new StringBuilder();
ScriptUtils.appendEncodedString(builder, summary);
summary = builder.toString();
builder = new StringBuilder();
ScriptUtils.appendEncodedString(builder, detail);
detail = builder.toString();
String script = MessageFormat.format(MESSAGE_OBJECT, messageId, summary, detail,
severity);
target.append(script);
}
{code}