Hi Jeromy,
Jeromy Evans wrote:
2nd, the parameters interceptor is called and sets properties of your
action. It cannot set primitives to null, so it does not write to
these properties.
3rd, the validation interceptors are executed. They cals the getters
of your action instance and observe the default values for the
primitives.
Thanks for the clean explanation. I somehow expected the validation
interceptor to do the work _before_ the Action would be invoked
(including the setters).
Personally, I never expose primitives as properties of an action
because null values are always legal over this interface. In the
special case of Boolean which can easily accidentally cause an NPE, I
always make the getter return false if the value is null..
This validation design jeopardizes the flexibility of using any POJO as
a target Action, using classes for which you don't have access to the
source code. Also promotes bad design practices i.e. potentiating NPEs.
I could try and open a "nice to have enhancement minor" JIRA ticket for
this? Maybe changing the Validation interceptor to do the validation
before is not a big deal. Only problem though is that doing it before,
it may try to validate request parameters that are not actually used in
the Action but maybe there is a way around this.
regards,
Giovanni
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]