In struts how can i validate the values filled into the text boxes or else using DynaValidatorForm,without using javascript.Actually with javascript it is working perfect but not without javascript, and i want without javascript?

Showing Answers 1 - 6 of 6 Answers

Amzad Basha

  • May 20th, 2006
 

Using the validate() method of the ActionForm class, the values filled in the form will be validated in the case there is no JavaScript for validating the form.

  Was this answer useful?  Yes

u.vellaisamy

  • May 21st, 2006
 

validator framework requires two xml files, namely

1.validator-rules.xml

2.validation.xml

validator-rules.xml 

          Files provides the rules for the ready made validation available in the framework.

ex:-

Required Field, Requrlare Expression, Email-id etc...

Validation.xml

<form name="validform">

<field property="name">

<arg0 key="validsform.name"/>

</field>

<var>

<var-name>max length</var-name>

  Was this answer useful?  Yes

siva kumar reddy

  • Aug 3rd, 2006
 

hi,

we configure validation="true" in config.xml file.then it takes care of execute the validate() method in formbean class.

cheers

siva

  Was this answer useful?  Yes

pardeep dureja

  • Sep 15th, 2006
 

HiStruts provide both client side and server side validation.for client side use for server side the best approach is to use DynaValidatorForm, specify form name in validation.xml and form property and its type and donot forget to make validate="true" in struts-config.xml at appropriate action.Cheers!Pardeep Dureja

  Was this answer useful?  Yes

Padmapriya

  • Jan 25th, 2007
 

Hi please follow thes steps for server side validation. I believe client-side validation is working fine for you and so telling you changes based on that. Hope you have given approriate entries in validation.xml and struts-config.xml.

1. just remove onsubmit attribute from the below given line in your jsp.

<html:form action="/Test.do" onsubmit="return validateTestForm(this)">

So it will look like

<html:form action="/Test.do" >

2. Add this error tag line before your form tag.
<html:errors />
<html:form action="/Test.do" >

3. Now comment validate method in your
FormBean.java

/***

public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request)
{
return null;

}
***/

4. Now your Form class should extend org.apache.struts.validator.ValidatorForm intead of ActionForm....

public class TestForm extends org.apache.struts.validator.ValidatorForm...

Thats all. It will work fine. All the best.

  Was this answer useful?  Yes

Hi guys!

we can validate form feilds in 3 ways.

1) using validator framework

2) using validate() method of formbean class. for this we need to set validate="true" in <action-mapping> tag of struts config.xml

3) otherwise we can validate in action class.. but this is extra round trip.

So in my view, using validator framework or validate() method of formbean class is good way.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions