Re: Conversion error message

2025-03-12 Thread Prasanth Pasala

Thank you.

On 3/12/25 12:57 AM, Lukasz Lenart wrote:

pon., 10 mar 2025 o 18:10 Prasanth  napisał(a):


com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator
Are we supposed to use this annotation for a method to override the
default validator?


This annotation only exposes any conversion errors for a given field. It
doesn't override anything. If you want to define a different message, using
.properties file is the solution.
https://struts.apache.org/core-developers/type-conversion.html#type-conversion-error-handling

Regards
Łukasz



Re: Conversion error message

2025-03-11 Thread Lukasz Lenart
pon., 10 mar 2025 o 18:10 Prasanth  napisał(a):

> com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator
> Are we supposed to use this annotation for a method to override the
> default validator?
>

This annotation only exposes any conversion errors for a given field. It
doesn't override anything. If you want to define a different message, using
.properties file is the solution.
https://struts.apache.org/core-developers/type-conversion.html#type-conversion-error-handling

Regards
Łukasz


Re: Conversion error message

2025-03-10 Thread Lukasz Lenart
śr., 5 mar 2025 o 16:21 Prasanth  napisał(a):

> They are, see below.
>
>
Ok, that should do the trick

Should I not be using
> com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator
> to set the message. This is not the class in
> com.opensymphony.xwork2.validator.validators with the same name.
>

Not sure what you mean by that, please take a look at the example - you
don't have to use ConversionErrorFieldValidator for common types.


Cheers
Łukasz


Re: Conversion error message

2025-03-05 Thread Prasanth

They are, see below.



Should I not be using com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator to set the message. This is not the class in com.opensymphony.xwork2.validator.validators with the 
same name.


Thanks,
Prasanth

On 3/5/25 12:37 AM, Lukasz Lenart wrote:

wt., 4 mar 2025 o 20:35 Prasanth  napisał(a):

I have the below line in the Action.properties file and it in the 
WEB-INF/classes folder in the sample package as the actual action class. But I 
am getting the standard error message rather than
the custom one.

The file must be in the same "package"/folder as the Java class, see
this example
https://github.com/apache/struts-examples/blob/main/type-conversion/src/main/java/org/apache/struts/example/NumberAction.java
https://github.com/apache/struts-examples/blob/main/type-conversion/src/main/resources/org/apache/struts/example/NumberAction.properties

and the name must match the action name


Regards
Łukasz

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




Re: Conversion error message

2025-03-04 Thread Lukasz Lenart
wt., 4 mar 2025 o 20:35 Prasanth  napisał(a):
> I have the below line in the Action.properties file and it in the 
> WEB-INF/classes folder in the sample package as the actual action class. But 
> I am getting the standard error message rather than
> the custom one.

The file must be in the same "package"/folder as the Java class, see
this example
https://github.com/apache/struts-examples/blob/main/type-conversion/src/main/java/org/apache/struts/example/NumberAction.java
https://github.com/apache/struts-examples/blob/main/type-conversion/src/main/resources/org/apache/struts/example/NumberAction.properties

and the name must match the action name


Regards
Łukasz

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



Re: Conversion error message

2025-03-04 Thread Prasanth
I have the below line in the Action.properties file and it in the WEB-INF/classes folder in the sample package as the actual action class. But I am getting the standard error message rather than 
the custom one.


invalid.fieldvalue.retirementDate=Invalid date format. Please use MM/dd/.

Thanks,
Prasanth

On 3/4/25 11:32 AM, Prasanth Pasala wrote:
I will try the xxxAction.properties file.  So @ConversionErrorFieldValidator is not an annotation to replace the xxxAction-validation.xml where we can specify the different validations we need and 
the corresponding messages?


Thanks,
Prasanth

On 3/4/25 9:44 AM, Lukasz Lenart wrote:

pon., 3 mar 2025 o 23:32 Prasanth  napisał(a):

Hi,

I have a custom message for conversion error as below. But the webpage is 
showing this and the default struts message. How do I suppress the struts 
default message? I am using Struts 6.7.0

  @ConversionErrorFieldValidator(fieldName = "retirementDate",  message = 
"Invalid date format. Please use MM/dd/.", shortCircuit = true)
  public Date getRetirementDate() {
  return retirementDate;
  }

   * Invalid field value for field "retirementDate".
   * Invalid date format. Please use MM/dd/.

Have you read this?
https://struts.apache.org/core-developers/type-conversion.html#type-conversion-error-handling

I would use @ConversionErrorFieldValidator in case there is no
built-in support for a given conversion, in other case adjusting
messages on XxxxAction.properties is all you need. See the example app
https://github.com/apache/struts-examples/tree/main/type-conversion


Cheers
Łukasz

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







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



Re: Conversion error message

2025-03-04 Thread Prasanth Pasala
I will try the xxxAction.properties file.  So @ConversionErrorFieldValidator is not an annotation to replace the xxxAction-validation.xml where we can specify the different validations we need and the 
corresponding messages?


Thanks,
Prasanth

On 3/4/25 9:44 AM, Lukasz Lenart wrote:

pon., 3 mar 2025 o 23:32 Prasanth  napisał(a):

Hi,

I have a custom message for conversion error as below. But the webpage is 
showing this and the default struts message. How do I suppress the struts 
default message? I am using Struts 6.7.0

  @ConversionErrorFieldValidator(fieldName = "retirementDate",  message = 
"Invalid date format. Please use MM/dd/.", shortCircuit = true)
  public Date getRetirementDate() {
  return retirementDate;
  }

   * Invalid field value for field "retirementDate".
   * Invalid date format. Please use MM/dd/.

Have you read this?
https://struts.apache.org/core-developers/type-conversion.html#type-conversion-error-handling

I would use @ConversionErrorFieldValidator in case there is no
built-in support for a given conversion, in other case adjusting
messages on XxxxAction.properties is all you need. See the example app
https://github.com/apache/struts-examples/tree/main/type-conversion


Cheers
Łukasz

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




Re: Conversion error message

2025-03-04 Thread Lukasz Lenart
pon., 3 mar 2025 o 23:32 Prasanth  napisał(a):
>
> Hi,
>
> I have a custom message for conversion error as below. But the webpage is 
> showing this and the default struts message. How do I suppress the struts 
> default message? I am using Struts 6.7.0
>
>  @ConversionErrorFieldValidator(fieldName = "retirementDate",  message = 
> "Invalid date format. Please use MM/dd/.", shortCircuit = true)
>  public Date getRetirementDate() {
>  return retirementDate;
>  }
>
>   * Invalid field value for field "retirementDate".
>   * Invalid date format. Please use MM/dd/.

Have you read this?
https://struts.apache.org/core-developers/type-conversion.html#type-conversion-error-handling

I would use @ConversionErrorFieldValidator in case there is no
built-in support for a given conversion, in other case adjusting
messages on XxxxAction.properties is all you need. See the example app
https://github.com/apache/struts-examples/tree/main/type-conversion


Cheers
Łukasz

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