开发者

escaped Ambersand in JSF i18n Resource Bundle

i have something like

<s:link view="/member/index.xhtml" value="My&#160;News" propagation="none"/>
<s:link view="/member/index.xhtml" value="#{msg.myText}" propagation="none"/>

where the value of myText in the messages.properties is

myText=My&#160;News

The first line of the example works fine and replaces the text to "My&nbsp;News", but the second that uses a value from the resource bundle e开发者_如何学Cscapes the ambersand, too "My&amp;#160;News".

I tried also to use unicode escape sequences for the ambersand and/or hash with My\u0026\u0023160;News, My\u0026#160;News and My\u0026nbsp;News in the properties file without success.

(Used css no-wrap instead of the previous used xml encoding, but would be interested anyway)


EDIT - Answer to clarified question

The first is obviously inline, so interpreter knows that this is safe.
The second one comes from external source (you are using Expression Language) and as such is not safe and need to be escaped. The result of escaping would be as you wrote, basically it will show you the exact value of HTML entity.
This is related to security (XSS for example) and not necessary i18n.

Previous attempt

I don't quite know what you are asking for but I believe it is "how to display it?".

Most of the standard JSF controls contain escape attribute that if set to false won't escape the text. Unfortunately it seems that you are using something like SeamTools which does not have this attribute.

Well, in this case there is not much to be done. Unless you could use standard control, maybe you should go and try to actually save your properties file as Unicode (UTF-16 BigEndian in fact) and simply put valid Unicode non-breaking space character. Theoretically that should work; Unicode-encoded properties files are supported in latest version of Java (although I cannot recall if it was Java SE 5 or Java SE 6)...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜