Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EL variable in JSF ResourceBundle

i read somewhere (don't find it anymore) that i can use EL Expresions in the resource bundle and then use it without changes in *.xhtml files.

some.text=#{someBean.stepsLeft} more

to switch the position of the variable in different languages. But actually it wont work. I can use Interpolator class to handle the parsing or add some.text.before some.text.after and let one of them empty. I would prefer it to use it without interpolator.interpolate() if possible.

like image 937
webstrap Avatar asked Jul 01 '11 11:07

webstrap


1 Answers

JSF resourcebundles does by default not resolve EL. It however by default supports MessageFormat API in combination with <h:outputFormat> and <f:param>.

some.text = {0} more

with

<h:outputFormat value="#{i18n['some.text']}">
    <f:param value="#{someBean.stepsLeft}" />
</h:outputFormat>

You can even explicitly make it a number type so that e.g. 1000 will be displayed as 1,000 or 1.000 depending on the view locale.

some.text = {0,number} more

For more formatting options see thus the MessageFormat API documentation.

like image 111
BalusC Avatar answered Sep 20 '22 01:09

BalusC