Issue Details (XML | Word | Printable)

Key: STR-2319
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Paul Benedict
Reporter: Nuno Furtado
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts 1

Validator validwhen comparisons of floats

Created: 29/Dec/04 12:15 PM   Updated: 26/Aug/07 11:45 PM
Return to search
Component/s: Core
Affects Version/s: 1.2.2
Fix Version/s: 1.4.0

Environment:
Operating System: All
Platform: PC
Issue Links:
Reference
 

Bugzilla Id: 32871


 Description  « Hide
I needed to validate a field if another one was diferent than zero, it should be
expected that i was able to do it like so :
<field property="outros" depends="validwhen">
<arg2 key="compostagemdataForm.outros.invalido"/>
<var>
<var-name>test</var-name>
<var-value>(qtoutros==0)</var-value>
</var>
</field>

For some reason this rule allways failed. i had to reformulate the rule :
<field property="outros" depends="validwhen">
<arg2 key="compostagemdataForm.outros.invalido"/>
<var>
<var-name>test</var-name>
<var-value>(qtoutros=='0.0') </var-value>
</var>
</field>

wich is weird! qtoutros is a String property on the bean, but can be converted
to float.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Don Brown added a comment - 30/Aug/05 02:08 PM
Reassigning to Struts as commons-validator does not have a validwhen validator.

Don Brown made changes - 23/Apr/06 04:49 AM
Field Original Value New Value
issue.field.bugzillaimportkey 32871 27610
Henri Yandell added a comment - 02/Feb/07 10:43 PM
Only ints are supported by the grammar at the moment, the '0.0' works because you're doing String comparison. I think that doing 0.0 without the quotes would have worked too, but it would really have been working at the String level and you'd have found bugs like STR-2321 when you got to comparison.

Paul Benedict made changes - 25/Aug/07 04:52 PM
Link This issue is related to STR-2321 [ STR-2321 ]
Repository Revision Date User Message
Struts #569926 Sun Aug 26 23:39:56 UTC 2007 pbenedict STR-2321 and STR-2319: Compare floats and doubles
Files Changed
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.java
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParserTokenTypes.java
MODIFY /struts/struts1/trunk/core/src/test/java/org/apache/struts/validator/TestValidWhen.java
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParserTokenTypes.txt
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenLexer.java
MODIFY /struts/struts1/trunk/core/src/test/java/org/apache/struts/validator/PojoBean.java
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.g

Paul Benedict made changes - 26/Aug/07 11:45 PM
Priority Minor [ 4 ] Major [ 3 ]
Assignee Struts Developers [ dev@struts.apache.org ] Paul Benedict [ paul4christ79 ]
Affects Version/s Future [ 21701 ]
Affects Version/s 1.2.2 [ 21695 ]
Fix Version/s 1.4.0 [ 21795 ]
Summary [validator] Validwhen and floats(maybe integers) Validator validwhen comparisons of floats
Paul Benedict made changes - 26/Aug/07 11:45 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]