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.valida
tor.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

Lukasz Lenart
2018-03-15 14:18 GMT+01:00 Vikul Aggarwal <[hidden email]>:

>  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.valida
> tor.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.

What's a type of the field?

I have pushed an additional code snippet to show how the IntRangeValidator works
https://github.com/apache/struts-examples/tree/master/form-xml-validation


Regards
Łukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]