• Post Reply Bookmark Topic Watch Topic
  • New Topic

Validation Messages in different h:Message components inside same form

 
prabal nandi
Greenhorn
Posts: 28
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My xhtml contains a global h:messages component which i am using to display all type of messages (There's only one form present in the page). There is a login component which is diaplyed inside a Dialog box (this is also present in the same form). The dialog box also contains another h:messages component, used only to display messages specific to Login. But my problem is whenever there is an input validation error for login components it is getting displayed by both the h:message components. which i want to redirect only to the Dialog box.
I am using primefaces as component suite.

Code is like:


Can anyone let me know how to redirect the input validation messages to a specific component. I dont want to use <h:message for="userId"> tag for each and every component inside the dialog. want to display it on top of the dialogBox.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the first thing you are doing wrong is that you are writing your own login service. DIY logins == hacked.

Beyond that, the JSF messages object supports 2 types of message targets. One is global, and shows up in an h:messages. The other is control-specific and shows up on an "h:message for=" element. Or on h:messages when you don't limit them to global-only.

You cannot "send" messages to a message display, you can only configure them in ways that cause the message display to select them.

If you need something more targeted, use more generic services such as h:outputText.
 
prabal nandi
Greenhorn
Posts: 28
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying... But you have confused me even more
First: What kind of login service you are talking about.. can you share any reference about the same. If it's more secure would love to go for it.

Second: My problem is, i have to use two h:message (one has to be a global message). Only those messages which i am creating inside the bean, i can route to <h:message for="element"/> rest of the input validation messages are display by the global component.
I dont want to use a custom validator, as the in-built validators are working fine for me.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything is more secure than Do-It-Yourself security. I've seen countless DIY systems over a long and evil career in J2EE and they all failed at a basic level. Security is too important to be left to people whose main job (and training) is elsewhere. It's a cruel Internet.

The J2EE standard includes a standard security system and it's well-documented. Practically any introductory book on J2EE will provide examples. And then they'll go and ruin it all by using a DIY "login page" as a coding example.

J2EE container-managed security comes in 2 basic parts: configuring the container-independent deployment descriptor (WEB-INF/web.xml) and configuring the container-dependent deployment descriptor (in Tomcat, this is the Context element and its Realm definition. Other servers have their own ways of doing it). Most of the work is done by the container so that you don't have to write (hackable) security code, just access rules.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!