I think I understand you but here's the question. Why would you want your
setter called for a null value? If you check the value of
myPropertyHasBeenSet, after it was set with a null value, you'll get true.
Of course this would suck because it was set to null. Is there a reason
you'd want it to be called even when the value is null?

-----Original Message-----
From: Adrian Perez Jorge [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 30, 2004 11:18 AM
To: [EMAIL PROTECTED]
Subject: 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.

Reply via email to