Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Weird JSF "h:messages" tag behavior  RSS feed

 
Cold Gin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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:

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
Krishna Srinivasan
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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 ]
 
Sunny Wear
author
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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" />
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or by specifying a label. If it is present, it will be used instead of the client id.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!