File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts validation" Watch "Struts validation" New topic
Author

Struts validation

manu Nihar
Greenhorn

Joined: Jul 22, 2010
Posts: 4
Hi All,

I have issues with struts validation framework.

In my application, i have a from ProducerForm and i have one producer object in it.



and I have Producer bean declared like below.




And here is my validation.xml

<field property="producer.phone1" depends="required,minlength,maxlength">



And the error i am getting is

" org.apache.commons.validator.ValidatorException: No such validation method: org.apache.struts.validator.FieldChecks.validateRequired("


am doing something wrong here.

Please help me.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Post your complete validation.xml or just the initial validator specification part of it


Have Fun with Java
little,little.. little by little makes a lot..
manu Nihar
Greenhorn

Joined: Jul 22, 2010
Posts: 4
Shankar Tanikella wrote:Post your complete validation.xml or just the initial validator specification part of it


Here is my validation.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">

<form-validation>
<formset>
<form name="producerForm">

<field property="producer.temporaryFlag" depends="required">
<msg name="required" key="errormessage.producer.temporaryFlag.required" />
</field>

<field property="producer.lockedFlag" depends="required">
<msg name="required" key="errormessage.producer.lockedFlag.required" />
</field>

<field property="producer.tinNo" depends="required">
<msg name="required" key="errormessage.producer.tinNo.required" />
</field>

<field property="producer.description" depends="required">
<msg name="required" key="errormessage.producer.description.required" />
</field>

<field property="producer.address1" depends="required">
<msg name="required" key="errormessage.producer.address1.required" />
</field>

<field property="producer.city" depends="required">
<msg name="required" key="errormessage.producer.city.required" />
</field>

<field property="producer.stateAbbrev" depends="required">
<msg name="required" key="errormessage.producer.stateAbbrev.required" />
</field>

<field property="producer.zipcode1" depends="required">
<msg name="required" key="errormessage.producer.zipcode1.required" />
</field>

<field property="producer.zipcode2" depends="required">
<msg name="required" key="errormessage.producer.zipcode2.required" />
</field>

<field property="producer.newEffDt" depends="required">
<msg name="required" key="errormessage.producer.newEffDt.required" />
</field>

<field property="producer.areacode" depends="required,minlength,maxlength">
<msg name="required" key="errormessage.producer.areacode.required" />
<msg name="minlength" key="errormessage.producer.areacode.required" />
<msg name="maxlength" key="errormessage.producer.areacode.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.phone1" depends="required,minlength,maxlength">
<msg name="required" key="errormessage.producer.phone1.required" />
<msg name="minlength" key="errormessage.producer.phone1.required" />
<msg name="maxlength" key="errormessage.producer.phone1.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.phone2" depends="required,minlength,maxlength">
<msg name="required" key="errormessage.producer.phone2.required" />
<msg name="minlength" key="errormessage.producer.phone2.required" />
<msg name="maxlength" key="errormessage.producer.phone2.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.extension" depends="required,minlength,maxlength">
<msg name="required" key="errormessage.producer.extension.required" />
<msg name="minlength" key="errormessage.producer.extension.required" />
<msg name="maxlength" key="errormessage.producer.extension.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.altAreacode" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.altAreacode.required" />
<msg name="minlength" key="errormessage.producer.altAreacode.required" />
<msg name="maxlength" key="errormessage.producer.altAreacode.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.altPhone1" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.altPhone1.required" />
<msg name="minlength" key="errormessage.producer.altPhone1.required" />
<msg name="maxlength" key="errormessage.producer.altPhone1.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.altPhone2" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.altPhone2.required" />
<msg name="minlength" key="errormessage.producer.altPhone2.required" />
<msg name="maxlength" key="errormessage.producer.altPhone2.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.altExtension" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.altExtension.required" />
<msg name="minlength" key="errormessage.producer.altExtension.required" />
<msg name="maxlength" key="errormessage.producer.altExtension.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.faxAreacode" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.faxAreacode.required" />
<msg name="minlength" key="errormessage.producer.faxAreacode.required" />
<msg name="maxlength" key="errormessage.producer.faxAreacode.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.faxPhone1" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.faxPhone1.required" />
<msg name="minlength" key="errormessage.producer.faxPhone1.required" />
<msg name="maxlength" key="errormessage.producer.faxPhone1.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

<field property="producer.faxPhone2" depends="minlength,maxlength">
<msg name="required" key="errormessage.producer.faxPhone2.required" />
<msg name="minlength" key="errormessage.producer.faxPhone2.required" />
<msg name="maxlength" key="errormessage.producer.faxPhone2.required" />
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>5</var-value>
</var>
</field>

</form>
<!-- End of validations for Login Form -->
</formset>
</form-validation>
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Manu,

1. Please use code tags, which makes it more easy to read
2. Verify if your validation.xml and validator-rules.xml uses the same DTD. If not then update to the actual and intended version

manu Nihar
Greenhorn

Joined: Jul 22, 2010
Posts: 4
Shankar Tanikella wrote:Hi Manu,

1. Please use code tags, which makes it more easy to read
2. Verify if your validation.xml and validator-rules.xml uses the same DTD. If not then update to the actual and intended version



Here is the DTD that i am using in validator-rules.xml.I am not seeing anything wrong it it.

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Manu,
Could you post your "required" validator config from validator-rules.xml .
something like

Which version of struts are you using?

Also check if org.apache.struts.validator.FieldChecks class has the method by name "validateRequired" in the library that you have added in the path.
This issue might occur due to incompatible struts version and its related validation config files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts validation