axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Fell" <sf...@salesforce.com>
Subject RE: Null values and calling a setter.
Date Tue, 30 Nov 2004 19:21:41 GMT
myPropertyHasBeenSet can be used to indicate that a value was explictly
sent (even if null), i.e. it handles the detection of elements that have
minOccur='0' and were never sent.

Not sent/nil are different in doc/lit soap.

Cheers
Simon

> -----Original Message-----
> From: Brown, Mike [mailto:mike.brown@dor.state.wi.us] 
> Sent: Tuesday, November 30, 2004 9:29 AM
> To: 'axis-user@ws.apache.org'
> Subject: RE: Null values and calling a setter.
> 
> 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:aperez@ignos.com]
> Sent: Tuesday, November 30, 2004 11:18 AM
> To: axis-user@ws.apache.org
> 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.
> 
> 
> 

Mime
View raw message