I need to override the default conversion messages So, I m trying to make a custom conversion error interceptor for my application which would be called instead of struts default interceptor Below mentioned is the code for that
public class MyConversionErrorInterceptor extends ConversionErrorInterceptor {
private static final long serialVersionUID = 1L;
protected Object getOverrideExpr(ActionInvocation invocation, Object value) {
ValueStack stack = invocation.getStack();
return (String)stack.findValue("myproj.item");
}
protected boolean shouldAddError(String propertyName, Object value) {
return true;
}}
Here is the struts.xml configuration mentioned.
<interceptors >
<interceptor name="conversionError" class="com.celtic.cmvs.webapp.interceptor.MyConversionErrorInterceptor" />
<interceptor-stack name="myDefaultStack">
<interceptor-ref name="conversionError" />
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
But it doesn't work. Thanks in advance
I see a few possibilities.
I have a tutorial on custom interceptors in my blog that may be useful: http://ddubbya.blogspot.com/2011/01/creating-custom-struts2-interceptors.html