PDA

View Full Version : Question related to messageSource



marceloverdijk
Oct 6th, 2009, 07:34 AM
Hi,
This question is just partly related to Roo.
I'm using Roo as "best-practice-template" for a Spring app.

I also used the messageSource definition in the springmvc-config.xml..

However I keep getting a:
No message found under code 'my.title' for locale 'en_US'.
when using <spring:message code="my.title" />

I checked the config a couple of time but don't see anything wrong.
When I inject the messageSource in a controller I can retrieve the message using getMessage(..) without a problem, so the bundle is loaded.

Then I bumped against this thread http://forum.springsource.org/showthread.php?t=18199 and I moved the messageSource bean from springmvc-config to applicationContext and the the <spring:message code="my.title" /> works!

Now I'm wondering why is it working inside springmvc-config for Roo. Is there some special magic going on there?

Ben Alex
Oct 6th, 2009, 10:37 PM
I'm having a hard time reproducing this problem.

Here's what I did:

1. Run script wedding.roo and quit Roo
2. Add to src/main/webapp/WEB-INF/i18n/messages.properties:


my.title="Hello world"

3. Add to src/main/webapp/WEB-INF/views/rsvp/create.jspx:


The message is: <spring:message code="my.title"/> <br/>


When I then mvn tomcat:run, and I elected to create a new RSVP, I correctly saw, The message is: Hello world".

So it seems to be working out-of-the-box as far as I can see. Can you please clarify what I need to do to reproduce the problem?

marceloverdijk
Oct 7th, 2009, 01:35 AM
Sorry Ben, I wasn't clear enough.

I'm not using Roo currently, but I'm "using" it's best practices, by using same applicationContext, urlrewrite etc. So I use it as an example for a cusom plain Spring app.

Including messageSource bean in webmvc-config. But the message was not displayed, unitil I moved messageSource to applicationContext.xml. I did this following some comments in a different thread I mentioned in my earlier post.

I'm just wondering why it works in Roo, I guess there is nothing special going on?