My goal is to have an actions properties be null if they are set due to request parameters that are empty strings.
I created an interceptor that is run before the default stack, which trims all values in invocation.getInvocationContext().getParameters() to null. However, this did not fix my problem; despite the parameters now being null (verified in the action using ParameterAware), the properties are still being set to empty strings.
Upon further reading, I see that the parameters interceptor is likely the cause, in particular that:
While this interceptor is being invoked, a flag (
ReflectionContextState#CREATE_NULL_OBJECTS) is turned on to ensure that any null reference is automatically created - if possible. See the type conversion documentation and theInstantiatingNullHandlerjavadocs for more information.
Is there some easy way to achieve my goal?
If worse comes to worse, it seems like it would be possible to extend the ParametersInterceptor class, and override the methods doIntercept(ActionInvocation invocation) and setParameters(Object action, ValueStack stack, final Map<String, Object> parameters). This just seems incredibly awkward for what, I assume, would be behaviour that many people would desire.