I'm looking for a way to convert my params in a parameterized text inside a JSF 1.2 xhtml page.
Let's say I have this parameterized message in my messages.properties
(please ignore the stupidity of this example):
EXAMPLE_TEXT=Right now {0} Euro is {1} US-Dollar.
And I would like the output to look like this:
Right now 1 Euro is 1.3658 US-Dollar.
Then my xhtml code looks like this:
<h:outputFormat value="#{messages.EXAMPLE_TEXT}">
<f:param value="#{backingBean.euroValue}" />
<f:param value="#{backingBean.dollarValue}" />
</h:outputFormat>
I already have implemented a converter (let's say its ID is bigDecimalConverter
) that converts numeric values to the particular formats.
My question now is: (How) can a converter be registered to the output's param values?
I imagine something like this (which unfortunately seems to not be possible):
<h:outputFormat value="#{messages.EXAMPLE_TEXT}">
<f:param value="#{backingBean.euroValue}" converter="bigDecimalConverter" />
<f:param value="#{backingBean.dollarValue}" converter="bigDecimalConverter" />
</h:outputFormat>
Asking google I found this thread, but it's no sufficient answer to my specific problem.
Thanks a lot in advance for any help!
You can have exact the same output with outputText
:
1) Change output to <h:outputText value="#{messages.TEXT1} #{backingBean.euroValue} #{messages.TEXT2} #{backingBean.dollarValue} #{messages.TEXT3}" />
2) Create method in backing bean which return full String and call it in output text.
(This answer was transformed from previous comment)