• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Validator Framework Error ...Depends String is not Found in validator-rules.

 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using struts validation framework for validating my fields....I use custom validation class to validation my fields for Number...
when i try to run application it shows following error...

" java.lang.NullPointerException: Depends string "cNumber" was not found in validator-rules.xml. "

my validation file entry is...

<field property="phoneNumber"
depends="cNumber">
<arg key="form.Number"/>
</field>

and validation rules.xml entry is ...

<validator name="cNumber"
classname="com.myApp.ContactNumberValidator"
method="validateContactNumber"
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"
depends=""
msg="errors.contactNumber"/>


I am not getting what is wrong with my code....

Please help me ?

Thanks

Rahul...
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems OK to me. Just make sure that you are using this validation rules file and that you set its location correctly in the validation plugin definition. I know that it's elementary, but I sometimes do much more stupid things
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Alaa,

But if i remove above validation rule then the rest form filed validation is working fine through same validation files in my application....

And It is says Depends string not found in Validation-rules.xml file.....

I Had correctly mapped the validation rule cNumber in my validation file...

Please help if someone knows about this...

Thanks

Rahul...
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please Help me, if someone know about above issues....

Thanks


Rahul.
 
Blade Fish
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,

you might want to remove the depends tag in the validator-rules.xml file.
It should ideally look like

<validator name="cNumber"
classname="com.myApp.ContactNumberValidator"
method="validateContactNumber"
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.contactNumber"/>

try and see if this works.

Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic