You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Adrian Perez Jorge <ap...@ignos.com> on 2004/11/30 18:17:45 UTC
Null values and calling a setter.
Hi all.
Let's imagine a client sends a bean, and let's imagine one of the bean
properties is null.
Now, at the server side (in reality in both sides), the bean is a
value object and the setter is like the following:
public MyBean() {
...
myPropertyHasBeenSet = false;
...
}
void setMyProperty(String myProperty) {
this.myProperty = myProperty;
myPropertyHasBeenSet = true;
}
What I can see is that axis will not call the setter of the property
with null value. According to this, I can't distinguish if the client
sent the property value (in this case any string or _null_) or if the
client didn't send any data for that property.
I can solve that situation by implementing my own BeanDeserializer (I
have implemented a BeanSerializer to check for the xxxHasBeenSet value
to be true before including that data to be sent).
But axis supposes that
(a) an empty bean constructor initializes all it's fields to null.
(b) setters do nothing starting from a bean created in (a) if the
property is to be set to null.
Is axis behaviour generic enough? Are there more real-life cases where
calling the setter with a null value by the deserializer is needed or
useful?
Thanks for your comments,
Adrian P.J.