Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Spring Boot in Practice
this week in the
Spring
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:
Campbell Ritchie
Tim Cooke
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Liutauras Vilda
Henry Wong
Devaka Cooray
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Al Hobbs
Carey Brown
Bartenders:
Piet Souris
Mikalai Zaikin
Himai Minh
Forum:
Struts
Struts two filed comparison
jaisai vijay
Ranch Hand
Posts: 70
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am trying to compare password and password confirmation fields using
Struts
validation. Please help me .
Thanks,
jaisai vijay
Ranch Hand
Posts: 70
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I forgot to mention the version. I am using struts 1.2.
Praveen Rajendran
Greenhorn
Posts: 21
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
guess the below code snippets should help you....
Courtesy to struts apache website which has the below example. More details available in
Validator Struts Site
<validator name="twofields" classname="com.mysite.StrutsValidator" method="validateTwoFields" msg="errors.twofields"/> <field property="password" depends="required,twofields"> <arg position="0" key="typeForm.password.displayname"> <var> <var-name>secondProperty</var-name> <var-value>password2</var-value> </var> </field>
public static boolean validateTwoFields( Object bean, ValidatorAction va, Field field, ActionErrors errors, HttpServletRequest request, ServletContext application) { String value = ValidatorUtils.getValueAsString( bean, field.getProperty()); String sProperty2 = field.getVarValue("secondProperty"); String value2 = ValidatorUtils.getValueAsString( bean, sProperty2); if (!GenericValidator.isBlankOrNull(value)) { try { if (!value.equals(value2)) { errors.add(field.getKey(), Resources.getActionError( application, request, va, field)); return false; } } catch (Exception e) { errors.add(field.getKey(), Resources.getActionError( application, request, va, field)); return false; } } return true; }
Thanks & Regards,
Praveen
jaisai vijay
Ranch Hand
Posts: 70
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Praveen,
Thanks for your help. I was doing this way
<field property="password2" depends="required,validwhen"> <arg key="prompt.password" /> <var> <var-name>test</var-name> <var-value>(*this* == password1)</var-value> </var> </field
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
reset button in struts
Need to send message to struts JSP after creating PDF
Struts 1.x, 2, jstl questions
creating a note or instruction on a form
Is there a struts tag for creating a instruction or hint to display on a webpage
More...