Ben
Ben

Reputation: 10288

How to format localized text in JSF

I'd like to keep localized text in a formatted manner (Using the <resource-bundle> in JSF)

For example:

in english.txt:

welcome_msg = <p>Hello <b>Friend</b></p>

in spanish.txt:

welcome_msg = <p> Ola <b>Hombre</b> commo esta? </p>

(Just random examples)

If I just use <h:outputText value="#{text.welcome_msg}" /> I will simply get the meta tags in the web page.

How can I achieve this?

Thanks!

Upvotes: 2

Views: 367

Answers (1)

Matt Ball
Matt Ball

Reputation: 359826

By default, <h:outputText/> escapes the <, >, and & characters. Use the escape attribute to disable this:

<h:outputText value="#{text.welcome_msg}" escape="false"/>

Be aware that this is now a potential security hole, depending on the source of the text that you are outputting.

See also: http://download.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/facelets/h/outputText.html

Upvotes: 4

Related Questions