Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

int feildvalidator with min and max <param> of struts2 is not validating properly

 
Jyothi Sree
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In my struts2 applicaion , i have a jsp page with "phone" feild in it for which i have applied validation using the
<field-validator type="int">
<param name="min">4</param>
<param name="max">20</param>
<message key="errors.range"/>
</field-validator>

int type min and max is not validating for me ,it is giving a negative number when i try to give the correct greater than 4 numbers

here are my jar files

commons-beanutils-1.8.0.jar
commons-digester-1.8.1.jar
commons-fileupload-1.2.1.jar
commons-logging-1.1.jar
freemarker-2.3.13.jar
mail.jar
ognl-2.6.11.jar
spring.jar
struts2-core-2.1.6.jar
struts2-dojo-plugin-2.1.6.jar
struts2-spring-plugin-2.1.6.jar
struts2-tiles-plugin-2.1.6.jar
tiles-api-2.1.2.jar
tiles-compat-2.1.2.jar
tiles-core-2.1.2.jar
tiles-jsp-2.1.2.jar
tiles-servlet-2.1.2.jar
xwork-2.1.2.jar
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really know what you're saying, but a phone number (a) isn't an integer, and (b) certainly isn't in the range of 4-20.

What are you really trying to validate? A phone number? Or an integer?
 
Jyothi Sree
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doesn't mean the phone number there , any integer take as an age where i need to valiadate age in between 4 and 20
<feild name="age">
<field-validator type="int">
<param name="min">4</param>
<param name="max">20</param>
<message key="errors.range"/>
</field-validator>
</feild>

Then in the frontend if i submit the value for age more then 4 and less than 20 itz showing a negative number and still showing an error message .
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

What's the data type in the action? I can't reproduce this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic