I am having a hard time finding documentation on something, which is making me think it is possibly something I shouldn't be trying to do. I know how to access the values in messages.properties from a gsp file using the tag <g:message, however, I have a couple of groovy files that I need to load a configurable string file in, and I wanted to put that string into messages.properties, however, I cannot seem to find a way to access the messages.properties files from the groovy class. The only thing I have found is how to do this in a controller,
But what I need is to load a string that is not an error message, it is something I am going to put into a list that will provide for a drop down list.
If anyone knows of a good resource they could point me to, I would appreciate it.
The message bundles are just sitting in the classpath. You should be able to just look them up via the standard Java Resource Bundle methods. That said, I'm curious as to why you want to store these in the messages.properties file since they clearly aren't messages. Are they even localizable Strings? If not, I'd put them in the database or Config.groovy.
Thank you Gregg,
I had some groovy code that was determining the contents of a list which would then be used on the page as a drop down list. I know this sounds strange, but I was getting all the values from a database, but have to replace one of the values with a different string. Something like
List = apple, pear, peach
and I want the drop down to read
List = apple, pear, banana
So, I wanted to store the string "banana" in the messages.properties file.
I have decided to put it into a different properties file, thanks for your input.
subject: Can I access messages.properties from a groovy class?