EL variable in JSF ResourceBundle

寵の児 提交于 2019-12-07 05:42:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/6547136/el-variable-in-jsf-resourcebundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!