• Post Reply Bookmark Topic Watch Topic
  • New Topic

fmt:message tag does not work with "bundle" param

 
anton moiseev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to use fmt:message tag with custom bundle (which is not specified in web.xml). Use jstl 1.2 with tomcat 7.0.2

The doc and multiple examples ower web show that I should symply use "bunde" tag parameter to load this custom bundle, so I put the tag in this way:

<fmt:message key="message_key" bundle="com.eyewain.messages.GeoTagNamesBundle"/>

and log shows the following error when tries to display this page:

org.apache.jasper.JasperException: Unable to convert string "com.eyewain.messages.GeoTagNamesBundle" to class "javax.servlet.jsp.jstl.fmt.LocalizationContext" for attribute "bundle": Property Editor not registered with the PropertyEditorManager
at org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:849)

But if I put the following construction instead, all works:

<fmt:bundle basename="com.eyewain.messages.GeoTagNamesBundle">
<fmt:message key="message_key"/>:
</fmt:bundle>

Can't understand the principal difference between those 2 constructions. This code is put inside my custom .tag file if that might make sense.

I could only find one relevant post with similar problem:
http://www.coderanch.com/t/516292/JSP/java/JSTL-not-registered-PropertyEditorManager-error

But it seems that their solution does not fit to my situation - I have <web-app version="2.5"...> tag in my web.xml - the version is not 2.3 and even not 2.4 as in the above post.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the bundle attribute is used on the <fmt:message> tag, it is expected to be a scoped variable referencing a pre-loaded localization context. You can't just specify a basename and expect it to load the context.

To load a localization context into a scoped variable from a basename, check out <fmt:setBundle>.
 
anton moiseev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank's for clarifications, seems that I misunderstood some examples I have found.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The docs aren't exactly crystal clear on this, but that's what I've found to work for me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!