wood burning stoves 2.0*
The moose likes Servlets and the fly likes validation in core java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "validation in core java" Watch "validation in core java" New topic
Author

validation in core java

pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 63
I want to validate text, number and email id in core java . When user enter invalid text or number or email-id it immediately show the error message in tool tip or in label using pattern matching
Please help me
Thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

I'll assume that this is in regards to a web UI as you posted it in the Servlets forum.

In that case, Java will not be of any help. If you want immediate feedback and display feedback in the browser, you'll need to employ JavaScript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Daniel Doboseru
Ranch Hand

Joined: Sep 26, 2011
Posts: 57
Well, from what I know, you can use listeners on servlets, and is not very complicated.
You can declare it very easy. Eg:

and afterwards deploy it as:

So basically what you have to do is using a some kind of lostfocus/onblur event to trigger the validation. But I'm not sure this would work, in which case, what Bear said seems the best option: use JavaScript, and after the data was validated pass it forward.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Server-side listeners cannot be used to monitor client-side events.
Daniel Doboseru
Ranch Hand

Joined: Sep 26, 2011
Posts: 57
Oh...I thought they can be triggered by the corresponding action on the listened object, no matter the source. My bad then. Thanks for the clarification Bear.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Bear Bibeault wrote:I'll assume that this is in regards to a web UI as you posted it in the Servlets forum.

In that case, Java will not be of any help. If you want immediate feedback and display feedback in the browser, you'll need to employ JavaScript.


Or you could use a combination of Ajax & Server side processing using Java... here's a link to read up more ...
Of course if you have simple validation like isNumberic, isString, maxLength - you've better off using javascript backed by a second level server side validation!! (Never trust what the client send you, ooh well almost never )


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation in core java