This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Weird JSF "h:messages" tag behavior

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I am displaying error messages via the <h:messages> tag, but this strange prefix shows up with the message:

j_id_jsp_1488097600_1:formField3: Validation Error: Value is less than allowable minimum of '5'

How can I suppress the j_id_jsp_1488097600_1:formField3: prefix, and what causes it to be displayed? Do I have something specified incorrectly? The tag in my JSP looks like this:



Thanks.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the key for the message is in a FacesMessageBundle.properties file with this value:

javax.faces.validator.LengthValidator.MINIMUM Value is less than allowable minimum of '{0}'

you faces config may have this in it:

<application>
<message-bundle>FacesMessageBundle</message-bundle>
</application>

The file name could be anything, this is just an example.
 
Cold Gin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying, Bob. I have the following in faces.config to reference my custom messages:



And then I have the application.properties file which resides in that package. The messages are being picked up correctly, I just don't understand why I am getting the extra verbage on the message...

Thanks.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try and add a new faces message bundle to play with the predefined messages. Here are the ones I use:


[ March 07, 2008: Message edited by: Bob Good ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Cold Gin",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Cold Gin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm. I tried adding all of your messages to my message bundle, but I got the same result... I also tried this, which got rid of the prefix, but now the replacement variable '{0}' does not get replaced with the minimum size inside of the message string. I also tried using '{1}' inside the message string:



Message file looks like:



Thanks.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your bundle is different than this bundle:

<application>
<message-bundle>FacesMessageBundle</message-bundle>
</application>

create a separate properties file for the java message bundle, and add to faces config like this. Works for me, and the message are overridden properly, and I can change the ones I do not like.
[ March 07, 2008: Message edited by: Bob Good ]
 
Cold Gin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bob - Thank you very much. Before reading your last post, I realized that the weird prefix seems to be caused by having my variable markers enclosed by single quotes '{0}' instead of double quotes i.e.) "{0}". The second thing is that I needed to have the message-bundle entry in the faces config also (just as you were saying). So my faces.config now looks like:



And finally, the messages:

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Cold Gin",
Please check your private messages.
-Ben
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
"Cold Gin",
Please check your private messages.
-Ben



So this is now "Cold Gin"'s second warning in the same thread.

"Cold Gin", if you do not change your display name by tomorrow, I will close your accout.

Mark
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSf Error Messages Example

[ March 12, 2008: Message edited by: Krishna Srinivasan ]
[ March 12, 2008: Message edited by: Krishna Srinivasan ]
 
author
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can also try to just add the requiredMessage attribute to any input tag in JSF 1.2, as that allows you to customize your error message.


<h:inputText id="name" required="true" requiredMessage="You must
enter a name" />
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or by specifying a label. If it is present, it will be used instead of the client id.
 
I found a beautiful pie. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic