Hi,
We had
the same problem here, when trying to inject special french characters in a
_javascript_ string (simple client validation on a JSF component). The _javascript_
string received a unicode translated value (é in our case),
breaking the _javascript_ code.
onfocus
="checkDefaultValue(this, '#{labels.menu_incident_number}');"The
reason why this breaks is hard to identify, I tested as well with simple alerts
on a plain HTML page and couldn't see this happen.
We
found a simple solution that works for us, replacing the simple
quotes by escaped double quotes:
onfocus
="checkDefaultValue(this, \"#{labels.menu_incident_number}\");"Surprisingly enough, the &#xxx; characters work fine when surrounded
this way. I can offer no real explanation about this behavior, but I hope this
might solve your problems.
Bye,
Arnaud
-----Message d'origine-----Hi,
De : Enrique Medina [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 18 janvier 2006 18:21
À : MyFaces Discussion; [EMAIL PROTECTED]
Objet : Re: unencode &# encodings in _javascript_
I face the same situation. The problem is that MyFaces encodes all HTML and all messages from the ResourceBundle, so the _javascript_ alert shows those annoying &nnn; characters....
2006/1/18, Werner Punz <[EMAIL PROTECTED]>:I do not know if there is a function but the \unnn notation works
definitely with alerts:
http://www.zid.tugraz.at/peter/_javascript_/unicode.html
I am not sure but the #nnn notation might be unicode numbers so they might
be the same numbers as in the \unnn notation
Mario Ivankovits schrieb:
> Hi!
>
> We merged our JSP project with JSF so we can slowly migrate to JSF at all.
> This has been done by heavily using the verbatim tag - and even if its
> butt ugly ;-) it works.
>
> Though, there is still one problem left.
> Now that the whole page renderes through the HtmlResponseWriter all the
> "umlauts" are converted to the &#nnn; form.
>
> Normally this is not a problem as the browser successfully handles it -
> normally - but not when using the _javascript_ function alert() to print
> such a string.
>
> What I need now is a _javascript_ function to unencode this string - is
> there already something in myfaces of do one know a library for this.
> I can create one myself, but I thought I'll ask before.
>
>
> Thanks!
> Mario
>
>