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

Validator framework

saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Hi All,

I am new to Validator framework.I am trying to validate a form on the browser itself.But the validation is not happening.Please find the code below.



this is my JSP form page which i want to validate

my Validation.xml

<formset>

<!-- An example form -->
<form name="firstForm">
<field
property="name"
depends="required">
<arg key="firstForm.name"/>
</field>
<field
property="password"
depends="required,mask">
<arg key="firstForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>

</formset>
[/code]

and i have put the subsequent entries in the struts-config.xml also.
I think onsubmit javascript event handling is not happening
please help

Thanks in advance
Saurav


Be Objectively Oriented.Explore the power of OOPs.
My Blog, Eclipse EMF Query committer.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Try changing validatefirstForm(this) to validateFirstForm(this).


Merrill
Consultant, Sima Solutions
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Thanks Merill for the reply.
I changed that it did not work.
The changing wont work because the name of my form in the
struts-config.xml is 'firstForm'
so validatefirstForm(this).
Please advise what needs to be done.
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
Hi man, can you post the struts-config.xml and validator-rules.xml too


SCJP 1.4 SCWCD 1.4 SCDJWS 1.4
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Looks like there may be other problems. It will help to have a look at the relevant portion of your struts-config.xml file.

Regarding the spelling issue: It's been my experience that Struts will normalize the capitalization of the JavaScript method regardless of whether your form name starts with an upper or lower case letter. You can verify this for sure by using your browser's "view source" function to see the JavaScript code that Struts added to your page. Look for the validateFirstForm function and you'll be able to see how it's capitalized. If you don't see any JavaScript code added to your page, you know there's some other problem.
[ July 25, 2007: Message edited by: Merrill Higginson ]
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Thanks Karthik and Merill for replying.

I checked the source , its generating the JS function



please help

thanks,
Saurav
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The part of your struts-config.xml file that I wanted to see with the action path definition for the action used in this form. Did you specify validate="true"?
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

oops........that might be the case......i will
check the code 2morrow as i dont have the code rite now
with me........need to check tommorow moring.....thanks
Merill for the pointer
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

thanks Merill again.....my validate option was kept as false.
Now its working fine after i tuned the struts-config.xml.
Nyanas Kandhan
Ranch Hand

Joined: Jan 27, 2009
Posts: 35
For an example on Struts Client Side JavaScript Validation refer here. Struts Client Side JavaScript Validation


regards,
Nyanaskandhan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validator framework