Search code examples
jsfjsf-2internationalizationfacelets

.properties storing long text values/lists/other


I am in the process of internationalising a website and I can't seem to find a way to store large paragraphs that my contain some other tags.

For example let's say I have this : (call this example 1)

<h1> the title </h1>
<p> 
    ... A very large paragraph ... <h:link value="click me" outocme="newPage"/> ... more text...
</p>

Or again something of this sort : (call this example 2)

<h1> check this list out </h1>
<ul>
    <li> ... text here </li>
    <li> ... text here </li>
    <!-- more items -->
</ul>

I am in JSF 2.0 and using the bundeled resource to internationalise my page and that's working fine as there are many examples how to do this.

But what I'd like to be able to do is something like this for example 1 (msg being my variable linked to my bundle)

<h1> #{msg['page.title']} </h1>
<p> #{msg['page.largeParagraph']} </p>

And example 2 would look like this :

<h1> #{msg['page2.title']} </h1>
<ul>
    #{msg['page2.myList']}
</ul>

Is there any way to do that, or do I have to resort to something like this (using example 1)

<h1> #{msg['page.title']} </h1>
<p> 
    #{msg['page.largeParagraph.part1']} <h:link value="#{msg['page.largeParagraph.link']} #{msg['page.largeParagraph.part2']}
</p>

The same would be for example 2 where I would need a different entry for each <li>.

What is the best practice when we are doing something of this sort?

Thank you for any input.

Edit :

It had occured to me that by default did escape characters. Therefore I have tried :

<p><h:outputText value="#{msg['page.paragraphWithLink']}" escape="false"/></p>

Unfortunately, this did not work for me.

Edit 2 :

Using escape="false" did work for <strong> but definetly does not work for <h:link>.


Solution

  • You cannot specify JSF components in the bundle file. They won't be parsed as part of the component tree. The webbrowser also doesn't understand JSF tags, it only understands HTML. Just plain HTML should work with <h:outputText escape="false">.

    page.paragraphWithLink=lorem ipsum <a href="newPage.xhtml">click me</a> dolor sit amet