Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Custom ResourceBundle class?...

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

(I'm actually using IceFaces, but this valid in a plain JSF context, too)
I'm trying to get around a very annoying problem: i have configured a resource bundle in my faces-config.xml file in order to retrieve messages according to the user's locale. The declaration is something like this:


In 80% of the cases I'm using this resource bundle in my jspx pages to display the interface in various languages. The problem is that when a key is missing from the properties file the server throws a nasty exception which I want to avoind by displaying the missing key name. For example, I'm using something like:

It the "login_username" key is missing from the bundle I want to display something like "??login_username??".

I know for a fact that this can be accomplished by implementing a custom resource bundle and overriding getString() so it catches MissingResourceException and returns whatever string I want instead BUT... I don't know how to tell JSF to use my resource bundle.

Thank you for your help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic