Search code examples
jsfinternationalizationseamjsf-1.2

Passing HTML into message bundle


I am in the process of 'Internationalising' my App, which is SEAM 2 / JSF 1.2 based

One thing that is annoying me is having HTML markup in the message bundle, I would like to avoid this if possible, say for example I have the following HTML

<p>Click <span class="link" id="trigCl">here</span> to register your account.</p>

I wanted to break this down into the following:

<h:outputFormat escape="false" value="#{messages['registerAccountText']}">
    <f:param value="<span class='link' id='trigCl'>#{messages['here']}</span>" />
</h:outputFormat>

With the following bundle entry:

registerAccountText=Click {0} to register your account.

But as you guessed, I get the following...

The value of attribute "value" associated with an element type "f:param" must not contain the '<' character.

Is there a) a way to get around this, or b) a better way to go about this (which doesnt involve completely re-writing the markup)?


Solution

  • Just came across this answer to a similar question from the omni-present BalusC which demonstrates a way to escape the HTML in the f:param

    <h:outputFormat escape="false" value="#{messages['registerAccountText']}">
        <f:param value="&lt;span class='link' id='trigCl'&gt;#{messages['here']}&lt;/span&gt;" />
    </h:outputFormat>
    

    Not exactly the cleanest solution but until I can move up to JSF 2.0 it will have to do