Thursday, October 2, 2008

ReferenceSyntaxException: how to use numbers as resource bundle message references?

Instead of using a string reference I would like to use numbers.

Resource bundle contains entries like this:
134=Please enter your company name.
Jsf tag has the following:

outputText value="#{bundle.134}"

Error Message:
[com.sun.faces.taglib.html_basic.OutputTextTag] -
javax.faces.el.ReferenceSyntaxException: Encountered ".134" at line 5, column 8.
Was expecting one of: ...[long list of characters]

Solution:
You can't refer to number with the dot notation ".134", use the bracket notation instead: outputText value="#{bundle['134']}"

No comments: