I am using a messages.properties bundle for my .xhtml page. I can access the keys and use them if they have a single name. Chaining keys for the same category and dividing them by .
causes problems.
eg messages.properties:
bookTitle=Title
I load my bundle like this:
<f:loadBundle var="msg" basename="messages"/>
and use the bundle like this:
<p:column headerText="#{msg.bookTitle}" filterBy="#{row.book.title}" filterMatchMode="contains">
<h:outputText value="#{row.book.title}" />
</p:column>
This work perfectly fine.
Problem:
Using:
book.title=Title
book.url=URL
I can't access the values with #{msg.book.title}
and get the following error message:
headerText="#{msg.book.title}": Property [title] not found on type [java.lang.String]
I'm using Lombok to generate getters and setters. I fear the problem is that the first key book
is retrieved as a String and then lombok tries to use the getTitle()
method on a String object (book) and thus throws an exception
Use
#{msg['book.title']}
instead. That should be it.
This is a syntax which, imho, should be used only for keys which have a dot as part of the name.
Btw, Lombok has no part in this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.