JSF2 ResourceBundleLoader override?
I need to have resource messages that contain EL expressions be resolved when loaded from a ResourceBundle. Basically I have a number of properties files containing the text. Some of the text will look like the following:
welcomeText=Welcome #{userbean.name}
The only possible way I can see this working currently is implementing a custom taglib so that instead of saying:
<f:loadBundle var="messages" basename="application.messages"/>
I would have to use
<mytaglib:loadBundle var="messages" basename="application.messages"/>
#{messages.welcomeText}
Given a user with username "User1", this should output
Welcome User1
My implementation would then use 开发者_Python百科a custom ResourceBundle class that would override handleGetObject, use the ELResolver to resolve variables etc....Ideas? suggestings? Implementations that are already available?
I appreciate your assistance.
Rather make use of <h:outputFormat>
and <f:param>
to display parameterized text. It's backed by the MessageFormat
API, the same rules as described in the API's javadoc will be applied.
E.g.
welcomeText=Welcome {0}
with
<h:outputFormat value="#{messages.welcomeText}">
<f:param value="#{userbean.name}" />
</h:outputFormat>
There it is for :)
精彩评论