Formatting messages on JSF page in JBoss Seam
In many scenarios we may need to format messages on the JSF page using JBoss Seam without calling a backing bean method, One typical example could be displaying a welcome message when the user logs in to the application. This tip explores a component called Interpolator in Seam which helps us the solution.
Lets assume we have defined a message property as welcome.message as below
#different message properties ... welcome.message= Welcome! Dear #0 ...
In the homepage.xhtml (jsf page), we come populate the greeting message with, say the logged in username, using interpolator as below:
....
<h:outputText value="#{interpolator.interpolate(messages['welcome.message'],identity.username)}"/>
....