• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrieve Internationalized messages from .java code base?

 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I retrieve messages from my resources bundles?
This I wish to do from the .java code, not the .xhtml.

I know it's possible in Struts and I assume there is a way in ICEfaces as well.

There's a lot of tutorials on the .xhtml front but none on how you fetch the messages from the .java code.

 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
argh, I do not have my code here so I can not check how I do it but I will answer tomorrow morning if someone else has not already told you how by then
BTW, do you use JSF 1 or JSF 2?
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use ICEfaces 2 which works upon JSF 2.
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright. This is how I do it. Not my own code so I can not take credit for it and alas I do not remember where I got it. Additionally there might be a better solution (JSF based for example) since this uses basic JDK API.

I have a helper class called LocaleHelper and inside it these two methods:

And you can use it for example with a call like this:

I can explain it further but I think it should be pretty obvious what it does. It uses basic java API as I explained so all the classes there are from java.util package or from java.text package
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your time.
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!