Struts - XWork validation - error message not taking parameters

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Struts - XWork validation - error message not taking parameters

Vikul Aggarwal
 Hi

I am using xwork validation to valid whether the value of an integer falls
in a valid range or not.

This is how the validator is configured:

<field-validator type="int">
            <param name="min">0</param>
            <param name="max">999999999</param>
            <message key="import.validRange">
            </message>
 </field-validator>

int validator is com.opensymphony.xwork2.validator.validators.
IntRangeFieldValidator

The message import.validRange is present in the properties file and is as
follows:

import.validRange=${fieldName}: You must enter a value in the range ${min}
and ${max}.

However, when the validation runs the message that is printed is as follows:

You must enter a value in the range ognl.NoConversionPossible and
ognl.NoConversionPossible.

The values of parameters min and max are not getting passed to the message.

Any pointers would be helpful.

I am using struts 2.5.13.

The Doctypes are as follows:
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" "
http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">

Regards,
Vikul Aggarwal
+91 960 357 0807 <096035%2070807>
Reply | Threaded
Open this post in threaded view
|

Re: Struts - XWork validation - error message not taking parameters

Greg Huber
You would get a better answer and more help on the user list rather than
here (dev list).

This works for me :

<field name="bean.qty">
        <field-validator type="required">
            <message key="bean.qty.required">unspecified key</message>
        </field-validator>
        <field-validator type="int">
            <param name="min">0</param>
            <param name="max">100</param>
            <message key="bean.qty.range">unspecified key</message>
        </field-validator>
    </field>

bean.qty.required=The Qty is required.
bean.qty.range=The Qty needs to be between ${min} and ${max} (inclusive).
invalid.fieldvalue.bean.qty=The Qty needs a number.


On 15 March 2018 at 11:48, Vikul Aggarwal <[hidden email]> wrote:

>  Hi
>
> I am using xwork validation to valid whether the value of an integer falls
> in a valid range or not.
>
> This is how the validator is configured:
>
> <field-validator type="int">
>             <param name="min">0</param>
>             <param name="max">999999999</param>
>             <message key="import.validRange">
>             </message>
>  </field-validator>
>
> int validator is com.opensymphony.xwork2.validator.validators.
> IntRangeFieldValidator
>
> The message import.validRange is present in the properties file and is as
> follows:
>
> import.validRange=${fieldName}: You must enter a value in the range ${min}
> and ${max}.
>
> However, when the validation runs the message that is printed is as
> follows:
>
> You must enter a value in the range ognl.NoConversionPossible and
> ognl.NoConversionPossible.
>
> The values of parameters min and max are not getting passed to the message.
>
> Any pointers would be helpful.
>
> I am using struts 2.5.13.
>
> The Doctypes are as follows:
> <!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" "
> http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
>
> Regards,
> Vikul Aggarwal
> +91 960 357 0807 <096035%2070807>
>