StrutsConversionErrorInterceptorpublic class StrutsConversionErrorInterceptor extends com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor
This interceptor extends {@link 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 {@link ConversionErrorInterceptor} for more information, as well as the Type Conversion documentation.
Interceptor parameters:
Extending the interceptor:
There are no known extension points for this interceptor.
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="params"/>
<interceptor-ref name="conversionError"/>
<result name="success">good_result.ftl</result>
</action>
|
Fields Summary |
---|
private static final long | serialVersionUID |
Methods Summary |
---|
protected java.lang.Object | getOverrideExpr(com.opensymphony.xwork2.ActionInvocation invocation, java.lang.Object value)
ValueStack stack = invocation.getStack();
try {
stack.push(value);
return "'" + stack.findValue("top", String.class) + "'";
} finally {
stack.pop();
}
| protected boolean | shouldAddError(java.lang.String propertyName, java.lang.Object value)Returns false if the value is null, "", or {""} (array of size 1 with a blank element). Returns
true otherwise.
if (value == null) {
return false;
}
if ("".equals(value)) {
return false;
}
if (value instanceof String[]) {
String[] array = (String[]) value;
if (array.length == 0) {
return false;
}
if (array.length > 1) {
return true;
}
String str = array[0];
if ("".equals(str)) {
return false;
}
}
return true;
|
|