Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Validation Messages in different h:Message components inside same form

 
Greenhorn
Posts: 28
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 24580
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 24580
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic