• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

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

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

Thanks


Rahul.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic