aspose file tools*
The moose likes Struts and the fly likes int feildvalidator  with min and max <param> of struts2 is not validating properly 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 "int feildvalidator  with min and max <param> of struts2 is not validating properly " Watch "int feildvalidator  with min and max <param> of struts2 is not validating properly " New topic
Author

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

Jyothi Sree
Ranch Hand

Joined: Jun 14, 2010
Posts: 41
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jun 14, 2010
Posts: 41
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: int feildvalidator with min and max <param> of struts2 is not validating properly
 
Similar Threads
Struts2 validation problem
Exception while configuring Struts2.1.6 with Tomcat 5.0
validation problem for cost : struts2
struts2 + jsp problem - ognl.MethodFailedException: Method "setId" failed for object
Struts2 + JSON : Getting Class Not Found Error