Hi,
I have the following situation:
1. educationDetails[0].degree.id is not chosen. (drop down return value =
-1).

OR

2. educationDetails[0].degree.id > 0 (the user chose one of the options from
the drop down)  which implies the marks should be atleast 35% and not more
than 100%

I tried the attached validation... but here is my dilema...

a. If I choose minimum percentage to be 35 in the validation file .. as
                    <var-name>min</var-name>
                    <var-value>35</var-value>
    the user will not have the choice to leave it as zero if he doesnt
choose the degree (zero I think is the most appropriate value for marks if
the degree is not chosen)


b. Because of (a) I am forced to leave the lower bound as 0 in the float
range validation. However, using validwhen tag .. when I tried to check 100
>= marks, it is doing a string comparision though the underlying datatypes
are floats. This behavior beats me ... because I know if I provide a
non-number in the field it would get converted to zero by JSP, but why
should the validator do a string comparision and not the int/float
comparisions? Afterall the validator is invoked after the form is
filled...it has the "luxury" to use "typed" comparisions... am i missing
something? Can someone fill in the gaps in my understanding and also suggest
How should I solve this problem in an elegant fashion?


 <field property="marks" indexedListProperty="educationDetails"
depends="float,floatRange,validwhen">
                <arg name="floatRange" key="${var:min}" resource="false"
position="1" />
                <arg name="floatRange" key="${var:max}" resource="false"
position="2" />
                <var>
                    <var-name>min</var-name>
                    <var-value>0</var-value>
                </var>
                <var>
                    <var-name>max</var-name>
                    <var-value>100</var-value>
                </var>
                <var>
                       <var-name>test</var-name>
                       <var-value>((educationDetails[0].degree.id == -1) or
((educationDetails[0].marks >= 35) and (100 >= educationDetails[0].marks)))
</var-value>
                </var>
                 <arg0 key="Education Details Percentage(s) greater than 35%
and less than 100% " resource="false"/>
            </field>


Thanks much.
Regards,
Raghu

Reply via email to