aspose file tools*
The moose likes Struts and the fly likes required validator not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "required validator not working" Watch "required validator not working" New topic
Author

required validator not working

Julien Marchal
Greenhorn

Joined: Jul 14, 2012
Posts: 8
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

Joined: Jul 20, 2012
Posts: 6
You should map in validator-rules.xml file with your form beans & serailized beans
Julien Marchal
Greenhorn

Joined: Jul 14, 2012
Posts: 8
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

Joined: Jul 23, 2008
Posts: 296

Search on google even you will get good examples for this.....
Julien Marchal
Greenhorn

Joined: Jul 14, 2012
Posts: 8
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

Joined: Jul 23, 2008
Posts: 296

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

Joined: May 17, 2011
Posts: 40
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

Joined: Jul 14, 2012
Posts: 8
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
 
subject: required validator not working
 
Similar Threads
Struts2: Problem with form validation using validation xml
Adding more than one validation to form field
short-circuiting validations
How to valdate password and confirm password using validation framework in struts2?
error in validation