• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to retrieve Internationalized messages from .java code base?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for your time.
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome.
 
reply
    Bookmark Topic Watch Topic
  • New Topic