• 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

Need some help customizing this error message

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

For the text fields on my JSF page that are required, I want to display a message ilke ...

ERROR! The "Name" field requires a value.

So I put an entry in my resources bundle that looks like ...



However, the actual message that gets dislpayed if someone doesn't enter a value on a text field is

ERROR! The "index:Name" field requires a value.

"index" is the id of the containing form. Any ideas how to get rid of the "index:" portion of the error message? Thanks, - Dave
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a "requiredMessage" attribute that can be used to attach per-control messages instead of falling back on the generic system-generated format.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But isn't there a way I can define a single message in my resource bundle, yet somehow have customize it so that it reads

The field 'Subject' is required.

Instead of having 32 messages in my resource bundle for 32 fields? Please provide an example. Thanks, - Dave
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Alvarado wrote:But isn't there a way I can define a single message in my resource bundle, yet somehow have customize it so that it reads

The field 'Subject' is required.

Instead of having 32 messages in my resource bundle for 32 fields? Please provide an example. Thanks, - Dave



Well, yes, actually, there is. You can put an attribute on the control to give it a display name to be used in the message in place of its system ID. However, since I'm too lazy to RTFM, I'll leave it to you.

Most of the time, I have the item messages displaying physically adjacent to their respective controls, so I just go with "*lt;- This item is REQUIRED" in red type. But you can do it your way as well.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the suggestion, but the erorr is still displaying incorrectly ...

ERROR! The "index:Name" field requires a value.

and I want to get rid of "index:" (the name of the form). I tried the attribute thing you suggested, but it didn't eliminate the problem ...



Here is what is in my resources bundle ...



If you can point me to a link or a term to search on Google, that would be awesome. I tried searching with the phrase from your thread, "an attribute on the control to give it a display name" but didn't get anything meaningful. Thanks, - Dave
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic