Log In
Sign Up and Get Started Blogging!
JoeUser is completely free to use! By Signing Up on JoeUser, you can create your own blog and participate on the blogs of others!
odyssey
A long wandering and eventful journey
Struts and SWT
Validations
Published on July 7, 2005 By
ApKa
In
Tutorials
In this article:
We will verify that the Username is not blank, has more than 5 character and less than 15 characters.
If the user makes valid entries , a successful logon page is displayed else an appropriate error is displayed.
First we require to add some entries in our application.properties file.
entryform.userName = User Name
entryform.passwordnotpatch = The Passwords entered do not match.Please Enter again
These entries will be used to display the error message to the user.
The basic messages like
errors.maxlength
errors.minlength
errors.required
are already available in application.properties file.
Now we will start with our validations:
1. We will verify that the Username is not blank, has more than 5 character and less than 15 characters
This requires updating struts-config.xml
action path="/entryScreen" type="strutsTutorial.EntryAction" name="EntryForm" attribute="entry" validate="true" input="/pages/Error.jsp"
forward name="success" path="/pages/success.jsp"
/action
The attribute field will be used to match this entry in the validation.xml.
We will update our validation.xml file now for the required attribute:
This is simple.
The form names will match on the attribute property : "entry"
The field to be validated: " userName "
“depends” define the rules on which validation is done : required,minlength,maxlength"
Sine the validations have been added on UserName field, so if we leave user name blank or enter less than 5 or more than 11 characters , we will see error.jsp, displaying the error message.
In the next posting , we will verify that the password and password check field are same.
"
Article Tags
tutorials
Popular Articles in this Category
Popular Articles from ApKa
New Job hiccups...
The Zahir
odyssey...........
Comments
No one has commented on this article. Be the first!
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
Richer content, access to many features that are disabled for guests like commenting on the forums.
Access to a great community, with a massive database of many, many areas of interest.
Access to contests & subscription offers like exclusive emails.
It's simple, and FREE!
Sign Up Now!
Meta
Views
» 2393
Comments
»
0
Category
»
Tutorials
Comment
Recent Article Comments
Gene Hackman Has passed.
Microsoft is Killing Off Sky...
GalCiv IV: Supernova Dev Jou...
Let's start a New Jammin Thr...
LightStar Design - March 202...
Abdi does it again...
LightStar Design - February ...
I'm Getting Another 'New' PC...
Windows File Manager Not Ope...
LightStar Design Windowblind...
Sponsored Links