File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

required validator not working

 
Julien Marchal
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm having an issue with my validator file here :



More precisely with required type validator, which are just not working at all (only them and except the date one, which is working for some reason). In addition when I input an invalid number in fields with validator type int or double, validation is working but I don't have my custom message. Instead I get "invalid value for field xxx...". Here the form :



Thanks
 
Dipeeka Suryawanshi
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should map in validator-rules.xml file with your form beans & serailized beans
 
Julien Marchal
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention but this is Struts 2. And I have no idea what this validation-rules.xml is for.
 
jatan bhavsar
Ranch Hand
Posts: 297
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search on google even you will get good examples for this.....
 
Julien Marchal
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did and all I found was related to Struts 1, that's why I mentioned I use Struts 2. Is this really needed for my validation ? I mean, from what I see this file looks like a mix between my validators.xml (where I register the validators) and the various ActionName-ActionAlias-validation.xml...
Anyway I tried creating one with what I knew but it doesn't seem to work.
 
jatan bhavsar
Ranch Hand
Posts: 297
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julien,

This is the link where example is given for struts 2.. http://viralpatel.net/blogs/struts2-validation-framework-tutorial-example/
If still it dosent work out for you let me know.

Regards
Jatan
 
tyte kyat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First you have to check your file name first. I hope you already did that. which is as follow



Second, you have to check whether you have registered validation interceptor for that particular action or not.

e.g.,


And, finally, you have to make sure in struts.xml file that you actually are pointing to the same page when your validation return "input".
 
Julien Marchal
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second, you have to check whether you have registered validation interceptor for that particular action or not.


What do you mean "for that particular action" ? I did turn on validation by declaring interceptors in struts.xml (also tried with default stack by the way) if that's what you meant.

I followed the official doc and the basic validation IS working (requiredstring and regex among other) I just have two issues i've described in my first post. Maybe I expressed myself wrong I'll just tell what I want instead :
- For my nombrestockproduit and seuilstockproduit fields, I want to prevent null inputs. For empty value I just get nothing right now. But I think by default it fills the field with "0" for some reason, which may cause the validation to work.
-Second, for the same field I want to make sure the inputs are int between specific values. Right now if I input a random string I get "Invalid field value for field xxx" in addition of my validator error message. But if I input a int outside of the specified range I only get my validator error message.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic