|
The new common EL expression language introduced with Java Server Faces eases development of modern web applications. A common usage scenario of EL expressions is, for instance, displaying localized text messages on the web-page by accessing the translated text via key from a properties file, e.g.
<f:loadBundle basename="messages" var="msg"/>
<h:outputText value="#{msg.this_is_a_key_for_my_testmessage"/>
A common problem arises when the key contains the dot ('.') character, as the dot has a very special function in EL. The problem is that most developers tend to organize the masses of keys in the properties files by creating some kind of hierarchy using dots in the keys, e.g.:
frontpage.title=blabla
frontpage.subtitle=abcdefg
Using this key directly will cause an error:
<h:outputText value="#{msg.frontpage.subtitle}"/>
it is required to escape the dot:
<h:outputText value="#{msg['frontpage.subtitle']"/>
et viola - this will work!
|