aspose file tools*
The moose likes JSF and the fly likes Need some help customizing this error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Need some help customizing this error message" Watch "Need some help customizing this error message" New topic
Author

Need some help customizing this error message

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

There's a "requiredMessage" attribute that can be used to attach per-control messages instead of falling back on the generic system-generated format.


Customer surveys are for companies who didn't pay proper attention to begin with.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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

Joined: Jun 25, 2001
Posts: 16061
    
  21

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

Joined: Jul 02, 2008
Posts: 436
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Need some help customizing this error message