You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Zepernick <Pa...@healthsmart.com> on 2018/02/13 16:36:13 UTC

Conversion Error Interceptor prevent errors for empty values

Can someone provide some clarification on if this interceptor should be adding a field error when an empty string is passed to a Integer in the action?  I am trying to prevent the field error from happening in this case.  It looks like it should not be happening according to the docs: https://struts.apache.org/core-developers/conversion-error-interceptor.html , or am I not understanding what it is saying here:

"This interceptor extends ConversionErrorInterceptor but only adds conversion errors from the ActionContext to the field errors of the action if the field value is not null, "", or {""} (a size 1 String array with only an empty String). See ConversionErrorInterceptor for more information, as well as the Type Conversion documentation"

Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

RE: Conversion Error Interceptor prevent errors for empty values

Posted by Paul Zepernick <Pa...@healthsmart.com>.
Yasser,

Thanks for pointing me to the right class.  After debugging, I found the problem was in my template and it was including the option body in the value when trying to set it to empty.  There is no issue with the Interceptor and it is working as documented.  Thanks for your help.

Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-----Original Message-----
From: Yasser Zamani [mailto:yasser.zamani@live.com] On Behalf Of Yasser Zamani
Sent: Wednesday, February 14, 2018 11:41 AM
To: user@struts.apache.org
Subject: Re: Conversion Error Interceptor prevent errors for empty values



On 2/14/2018 5:13 PM, Paul Zepernick wrote:
> Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a Integer like this: auditForm.incorrectAuditReason.id  I am using the rest plugin which is including it in the stack.  I have attached the source from Maven.  Where is the check being done in the code?  I see the check for shouldAddError() always returning true.
>

No you should check
`org.apache.struts2.interceptor.StrutsConversionErrorInterceptor`
(prefixed with `Struts`) instead. Could you put a break point on it's `shouldAddError` method and see what happens when you post auditForm.incorrectAuditReason.id?

> I have attempted to override the default interceptor by adding this in my package and overriding the shouldAddError(), but it continues to call the default Struts ConversionErrorInterceptor.
>
> <interceptor name="conversionError"
> class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/>
>
I think you should define your stack including your new interceptor and ref it in your action definition.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Conversion Error Interceptor prevent errors for empty values

Posted by Yasser Zamani <ya...@apache.org>.

On 2/14/2018 5:13 PM, Paul Zepernick wrote:
> Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a Integer like this: auditForm.incorrectAuditReason.id  I am using the rest plugin which is including it in the stack.  I have attached the source from Maven.  Where is the check being done in the code?  I see the check for shouldAddError() always returning true.
> 

No you should check
`org.apache.struts2.interceptor.StrutsConversionErrorInterceptor`
(prefixed with `Struts`) instead. Could you put a break point on it's
`shouldAddError` method and see what happens when you post
auditForm.incorrectAuditReason.id?

> I have attempted to override the default interceptor by adding this in my package and overriding the shouldAddError(), but it continues to call the default Struts ConversionErrorInterceptor.
> 
> <interceptor name="conversionError" class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/>
>
I think you should define your stack including your new interceptor and
ref it in your action definition.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Conversion Error Interceptor prevent errors for empty values

Posted by Paul Zepernick <Pa...@healthsmart.com>.
Trying the attachment again as a txt

Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-----Original Message-----
From: Paul Zepernick [mailto:Paul.Zepernick@healthsmart.com] 
Sent: Wednesday, February 14, 2018 8:44 AM
To: user@struts.apache.org
Subject: RE: Conversion Error Interceptor prevent errors for empty values

Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a Integer like this: auditForm.incorrectAuditReason.id  I am using the rest plugin which is including it in the stack.  I have attached the source from Maven.  Where is the check being done in the code?  I see the check for shouldAddError() always returning true.

I have attempted to override the default interceptor by adding this in my package and overriding the shouldAddError(), but it continues to call the default Struts ConversionErrorInterceptor.

<interceptor name="conversionError" class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/>



Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-----Original Message-----
From: Yasser Zamani [mailto:yasser.zamani@live.com] On Behalf Of Yasser Zamani
Sent: Wednesday, February 14, 2018 4:25 AM
To: user@struts.apache.org
Subject: Re: Conversion Error Interceptor prevent errors for empty values



On 2/13/2018 8:06 PM, Paul Zepernick wrote:
> Can someone provide some clarification on if this interceptor should be adding a field error when an empty string is passed to a Integer in the action?

No, it should not be happening for `conversionError` interceptor. Does it happen?

>   I am trying to prevent the field error from happening in this case.  It looks like it should not be happening according to the docs: https://struts.apache.org/core-developers/conversion-error-interceptor.html , or am I not understanding what it is saying here:
>
> "This interceptor extends ConversionErrorInterceptor but only adds conversion errors from the ActionContext to the field errors of the action if the field value is not null, "", or {""} (a size 1 String array with only an empty String). See ConversionErrorInterceptor for more information, as well as the Type Conversion documentation"

You understood correctly. I reviewed it's code and looks like it should behave as above. Doesn't it?

I also saw `conversionError` is already included in default stack.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.


RE: Conversion Error Interceptor prevent errors for empty values

Posted by Paul Zepernick <Pa...@healthsmart.com>.
Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a Integer like this: auditForm.incorrectAuditReason.id  I am using the rest plugin which is including it in the stack.  I have attached the source from Maven.  Where is the check being done in the code?  I see the check for shouldAddError() always returning true.

I have attempted to override the default interceptor by adding this in my package and overriding the shouldAddError(), but it continues to call the default Struts ConversionErrorInterceptor.

<interceptor name="conversionError" class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/>



Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-----Original Message-----
From: Yasser Zamani [mailto:yasser.zamani@live.com] On Behalf Of Yasser Zamani
Sent: Wednesday, February 14, 2018 4:25 AM
To: user@struts.apache.org
Subject: Re: Conversion Error Interceptor prevent errors for empty values



On 2/13/2018 8:06 PM, Paul Zepernick wrote:
> Can someone provide some clarification on if this interceptor should be adding a field error when an empty string is passed to a Integer in the action?

No, it should not be happening for `conversionError` interceptor. Does it happen?

>   I am trying to prevent the field error from happening in this case.  It looks like it should not be happening according to the docs: https://struts.apache.org/core-developers/conversion-error-interceptor.html , or am I not understanding what it is saying here:
>
> "This interceptor extends ConversionErrorInterceptor but only adds conversion errors from the ActionContext to the field errors of the action if the field value is not null, "", or {""} (a size 1 String array with only an empty String). See ConversionErrorInterceptor for more information, as well as the Type Conversion documentation"

You understood correctly. I reviewed it's code and looks like it should behave as above. Doesn't it?

I also saw `conversionError` is already included in default stack.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.


Re: Conversion Error Interceptor prevent errors for empty values

Posted by Yasser Zamani <ya...@apache.org>.

On 2/13/2018 8:06 PM, Paul Zepernick wrote:
> Can someone provide some clarification on if this interceptor should be adding a field error when an empty string is passed to a Integer in the action?

No, it should not be happening for `conversionError` interceptor. Does
it happen?

>   I am trying to prevent the field error from happening in this case.  It looks like it should not be happening according to the docs: https://struts.apache.org/core-developers/conversion-error-interceptor.html , or am I not understanding what it is saying here:
> 
> "This interceptor extends ConversionErrorInterceptor but only adds conversion errors from the ActionContext to the field errors of the action if the field value is not null, "", or {""} (a size 1 String array with only an empty String). See ConversionErrorInterceptor for more information, as well as the Type Conversion documentation"

You understood correctly. I reviewed it's code and looks like it should
behave as above. Doesn't it?

I also saw `conversionError` is already included in default stack.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org