473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

validateFloatRange Incorrect Behaviour - Using Struts

Hello,

I'm validating a form containing various types of data. One of the fields to be validated is an amount which must be between 0.01 and 999999.99.

The code for this field validation in the validation.xml is;

Expand|Select|Wrap|Line Numbers
  1. <field property="amount" depends="required,webxvalidator,floatRange">
  2.     <arg0 key="label.authorization.txn.amount"/>
  3.     <arg1 name="floatRange" key="${var:min}" resource="false"/>
  4.     <arg2 name="floatRange" key="${var:max}" resource="false"/>
  5.     <var><var-name>min</var-name><var-value>0.01</var-value></var>
  6.     <var><var-name>max</var-name><var-value>999999.99</var-value></var>
  7.     <var>
  8.         <var-name>dataType</var-name>
  9.         <var-value>amount</var-value>
  10.     </var>
  11. </field>
  12.  
And within the validator-rules.xml;

Expand|Select|Wrap|Line Numbers
  1.       <validator name="floatRange"
  2.             classname="org.apache.struts.validator.FieldChecks"
  3.                method="validateFloatRange"
  4.          methodParams="java.lang.Object,
  5.                        org.apache.commons.validator.ValidatorAction,
  6.                        org.apache.commons.validator.Field,
  7.                        org.apache.struts.action.ActionMessages,
  8.                        javax.servlet.http.HttpServletRequest"
  9.               depends="float"
  10.                   msg="errors.range"/>
  11.  
This normally works fine, and any number outside the range will flag and display the label.authorization.txn.amount from MessageResources.properties.

But, a small range of numbers, which in this case is 1,000,000.00 to 1,000,000.03 will not flag up as being outside the range! This causes problems later as the value is accepted and is being used will being outside predefined ranges elsewere.

The same thing happens across the board if I lower the max variable to any value. The max+.01 to max+.04 will always be (incorrectly) accepted as within the range.

Has anyone seen this before? See anything blatent I'm doing wrong?

Any ideas would be grand.

Thank you,

Paul
Aug 29 '07 #1
2 1346
Nepomuk
3,112 Expert 2GB
This is the Java Forum, not the JavaScript Forum. By the way, you didn't state, why you are posting the code (e.g. "need help with...").
Aug 29 '07 #2
Whoops sorry, my mistake.

I'll re-post it in the correct place.

Cheers,

Paul
Aug 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Cedric | last post by:
Hello, I'm developping my first Struts application. I've got this error: Cannot find message resources under key org.apache.struts.action.MESSAGE web.xml <servlet>...
1
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader ...
3
by: shanmukhi | last post by:
hi all, i got a problem with struts. iam unable to find it. i have written an action class, form bean class and a jsp page on submitting form, request is going to action class but it is not...
3
by: PaulCarmo | last post by:
Hello, I'm validating a form containing various types of data. One of the fields to be validated is an amount which must be between 0.01 and 999999.99. The code for this field validation in the...
1
by: shrik | last post by:
hi everybody. I have following problem. There are two pages. index.jsp and main.jsp in my application Index.jsp contains logging interface in . It submits password and userid to loginform bean. ...
8
by: ajos | last post by:
hi frnds, the situation is im developing a web application in struts-- my specifications-eclipse3.2.2,struts1.1,tomcat5.5.23 mysql5.0 db. the scenario-i have a jsp page which adds the...
1
by: ajos | last post by:
hi friends, Im developing a web based project in struts framework, i have certain forms in them, which contain date field among others. For this purpose i got a calender pop-up from here tigra ....
1
by: NamelessNumberheadMan | last post by:
I can't seem to get Struts 2 validations to work. I have been converting from Strust 1 to Struts 2. So far I've refactored all the code (for this particular module) on the back end, rewrote the jsp...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.