Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-14-2008, 04:10 PM
Member
 
Join Date: Jul 2008
Location: chennai
Posts: 9
Satheeshhere is on a distinguished road
Struts validator framework
Hi friends,

Im new to struts framework and using struts1.3
thing is i want to do client side validation using validator framework.

server side validation (ie <html:erros> ) is working fine.but not client side validation.
im using <html:javascript formName="Homeform">
and <html:form action="/action.do" method="post" onsubmit="return validateHomeform(this);">

Homeform is bean which extends ValidatorForm..

but im not getting alertbox n all.can u guys pls help me


If u r not able to understand means i can explain in detail.
Lukin forward ur answers.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-15-2008, 02:27 PM
Member
 
Join Date: Jul 2008
Posts: 6
ganesan is on a distinguished road
Hi you need to do the Homeform fields for client side validation using validation.xml file.

for eg.........

assume passwordfied and confirm password fields

<form name="Homeform">
<field property="password" depends="required,minlength">
<arg0 key="home.password"/>
<arg1 key="${var:minlength}" name="minlength" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
</field>
<field property="confirmpassword" depends="validwhen">
<msg name="validwhen" key="errors.confirmpassword.match"/>
<var>
<var-name>test</var-name>
<var-value>(*this* == password)</var-value>
</var>
</field>

In Properties file
home.password=password
errors.confirmpassword.match=password does not match

try to this logic you can get the output
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-15-2008, 03:05 PM
Member
 
Join Date: Jul 2008
Location: chennai
Posts: 9
Satheeshhere is on a distinguished road
Hi ganesan..thx much 4 ur reply.

but i already defined validation.xml like this for "required" validation

<form-validation>
<formset>
<form name="HomeForm">
<field property="filepath" depends="required">
<arg key="required.index" />
</field>
</form>

i hav properties file also..
and my validator-rules.xml looks like this
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-15-2008, 03:08 PM
Member
 
Join Date: Jul 2008
Location: chennai
Posts: 9
Satheeshhere is on a distinguished road
(CONTINUATION)

<validator name="required"

classname="org.apache.struts.validator.FieldChecks "

method="validateRequired"

methodParams="java.lang.Object,

org.apache.commons.validator.ValidatorAction,

org.apache.commons.validator.Field,

org.apache.struts.action.ActionMessages,

org.apache.commons.validator.Validator,

javax.servlet.http.HttpServletRequest"

msg="errors.required"/>

Last edited by Satheeshhere : 07-15-2008 at 03:25 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-15-2008, 03:26 PM
Member
 
Join Date: Jul 2008
Location: chennai
Posts: 9
Satheeshhere is on a distinguished road
server side validation is working very fine..
but stil couldnt get client side alert box.

i think there s some thing wrong in my validatior-rules.xml for only client side validation.
is it?

Ganesh pls im awaitin for ur reply.thx in advance
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-15-2008, 04:49 PM
Member
 
Join Date: Jul 2008
Posts: 6
ganesan is on a distinguished road
Hi satheesh

you should copy the validator error message from validator-rules.xml to properties file.


1. In form bean u must extend ValidatorForm
2. u put the plugins in struts-config.xml
3. define the validation rules in validation.xml(for eg i was send previouse message)
4. you need not to any change in validator-rules.xml file
5.call java script code in jsp file


follow this sure you can get the output
Regards

Ganesh
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-15-2008, 04:59 PM
Member
 
Join Date: Jul 2008
Location: chennai
Posts: 9
Satheeshhere is on a distinguished road
Hi ganesh.

i have done all those things as u said properly.so that only my server side validation s working fine.

thing is validator-rules.xml wat i have has some errors..

Can you just send your validatior-rules.xml? it wil be helpful if u do that..
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-25-2008, 02:48 PM
Member
 
Join Date: Jul 2008
Posts: 3
anandguna is on a distinguished road
Make sure the javascript formname similar to the <form-bean> name mentioned in the struts config.xml file.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 08-05-2008, 08:16 AM
Member
 
Join Date: Dec 2007
Posts: 38
rameshraj is on a distinguished road
For client side I think the javascript code should be used,what you have done using the validation.xml is processed on the server and so ur server side validation is working.Then go for javascript as used in almost all sites.Define the javascript method and call them when the form is submitted or some thing change happens in the form elements.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 08-19-2008, 06:44 AM
Member
 
Join Date: Aug 2008
Posts: 1
beck is on a distinguished road
Today I have the same problem, I'm using Struts1.1, its validator-rule.xml dtd is 1.0.
I found you are validating a 'password' field, then I came across the problem that it can't alert a message when the field'e length is less then 'minlength' I defined in validation.xml. You can find the javascript code of function validateMinlength() in validator-rule.xml, there is a piece of follows:
if (field.type == 'text' || field.type == 'textarea')
so it won't validate field of 'password' type, you can change it to
if(field.type == 'text' || field.type == 'textarea' || field.type == 'password')
then it will work fine. I'm not sure whether it is a bug or there is some other reasons.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Validator validwhen getsridhara Web Frameworks 0 05-30-2008 12:58 PM
Struts Validator anoop.retnakumar Web Frameworks 1 03-05-2008 08:54 AM
Struts Validator Framework Albert Web Frameworks 2 02-15-2008 01:01 PM
Struts Validator - JScript version of Validator ´validwhen´ Felissa Web Frameworks 1 07-06-2007 06:39 PM
Validator framework Daniel Web Frameworks 1 06-25-2007 07:29 AM


All times are GMT +3. The time now is 08:19 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org