Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pass the internationalized field name to a h:message?  RSS feed

 
Jacek The Java Newbie
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A typical h:message will display a common error like:

"firstName": Value is required.

This of couse looks very unprofessional, since the field name is taken directly from the name of the property in the backing bean. A pro error message would say:

"First Name": Value is required.

and the "First Name" part of course would be internationalized.

Unfortunately, there seems to be no way to make this happen! I always get this ugly, unprofessional error message instead of a nice, polished error where you can pass the proper label for a field, instead of just using the raw field name.

How can this be accomplished.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

"Jacek the Java Newbie" is, for us, an "ugly, unprofessional" name, according to our naming policy (which you may not have read on your way in.) The policy requires that JavaRanch display names consist of a real (sounding) first and last name separated by a space.

Given the nature of your question, I'm sure you understand! You can change your display name here; please do so right away. I can't answer your question personally, but I imagine that if you follow the rules around here, someone will come along shortly and answer it for you.
[ February 11, 2006: Message edited by: Ernest Friedman-Hill ]
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jacek,

In your bundle you should have something like this:

firstNameRequired=First name is required

Then when your validation fails you simply need to add a message for your
firstName field in the FacesMessage thingy. I'm new to JSF as well. I've found that getting a good JSF book and reading about the basics helps but you need to spend endless hours alone locked in your study and no music :roll:

I also found this presentation by David Geary very helpful: http://www.intertech-inc.com/Resource/usergroup/Java%20Server%20Faces.pdf

Hoep that helps
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article was recently referenced in a similar thread:

http://www.oracle.com/technology/pub/articles/masterj2ee/j2ee_wk7.html
[ February 15, 2006: Message edited by: Jeff Albertson ]
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe I have posted a better explanation of how this is done here
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!