• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

h:messages prints error message twice on first submit  RSS feed

 
Greenhorn
Posts: 4
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to JSF and I have been trying to solve this since a week now.

I am using <h:messages> to display on the top of the page, all the errors on the page.

Issue is when I submit the form for the FIRST TIME, a single error message gets displayed twice.
But when I submit the form again, the error message gets displayed just once which is what I want.

Can anyone please explain why <h:messages> is behaving like this.

Appreciate it. Thanks.
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your page tags that are causing this?

you should be aware that there is an attribute specific to <h:messages> that is not available in the component-specific <h:message> tag: . This will display only messages that are NOT queued for a specific component. However, if you are not using this attribute, and you have component-specific messages as well, it will display both...once with the <h:message> tag, and once with the <h:messages> tag. I don't know if that's the problem, but I've had similar behavior caused by that default behavior.
 
Sagar Salimath
Greenhorn
Posts: 4
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tom,

I got the issue.
Issue was I had two messages. One tied to the component and the other one was not.
So, the one not tied with the component was a redundant code. How stupid of me

Regards,
Sagar
 
Tom Fulton
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"You learn how to avoid mistakes from experience. Unfortunately, you only gain experience by making mistakes".

I've done the same thing a number of times, often when I am copying code and adding some functionality. I don't carefully check to see if I am duplicating something that was already happening in the copied code.
 
Sagar Salimath
Greenhorn
Posts: 4
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very true Tom. . miss some take some and mistake some. part of learning

I have another one. Regarding jsfcljs.
Will post it if I am not able to resolve it .

Thanks.
Take care.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!