How to specify max param in Struts2's Date Field Validator?

481 Views Asked by At

This is my validation field of date type and current is an hidden variable having get & setter in action class:

<param name="min">01/01/1920</param>
<param name="max">${new java.util.Date(current}</param>  
<message>Your Birth date must be less than ${min} and ${max} date!</message>

Please help the above code is working for min but the max value is blank..

1

There are 1 best solutions below

0
On

Action:

private Date current;

public Date getCurrent(){
    return current;
}

Validator:

<field name="birthday">
    <field-validator type="date">
        <param name="minExpression">01/01/1920</param> 
        <param name="maxExpression">${current}</param> <!--calls getCurrent();-->
        <message>
            <![CDATA[ Your Birth date must be between ${min} and ${max}! ]]>
        </message>             
    </field-validator>
</field>

Also take a look at the documentation, it's all explained there.