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 axisnewbie <ax...@myway.com> on 2003/09/24 21:37:09 UTC

how to deal with optional fields in parameter bean

Hello Axis Users,

I have a method like userUpdate(UserBean bean). 
class UserBean{
private String firstName = null;
private String lastName = null;
private Date optionalField1 = new Date(1999, 1, 12);
private int optionalField2 = 31432811;
private String optionalField3 = "This IS an Example of NOT_SET";
..
public UserBean(){..}
public UserBean(String firstName, String lastName){..}
get[set]FirstName(){..}
get[set]LastName(){..}
get[set]optionalField1(){..}
get[set]optionalField2(){..}
get[set]optionalField3(){..}
...
get[set]optionalFieldN(){..}
}

In java, if someone wants to create a userBean, they will just call the two parameters constructor with 2 required fields. If they want to  set an optional field, they will explicitly call its setter methods. If they don't call one setter methods, the optional field will stay with some kind of NOT_SET value which is predefined. This is pretty straightforward and easy in pure java solution.

However, when transfering the UserBean object over webservice (between Axis & .NET), to tell the server that an optional field has not been set, the client will have to call the setter method with the predefined the NOT_SET value, otherwise the server will get a null/zero type value which could be a valid value for the userbean.

Since there are just too many optional Fields, it has ruled out the possibility to require the user to explicitly call all the setter methods with their NOT_SET values (implementation will be revealed this way.)

My question is if there is another way or if there is a standard way dealing with optional fields in parameter when Nil, NULL, zero is a valid value.

Thanks for your time.

An AXIS Newbie


_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com

Re: how to deal with optional fields in parameter bean

Posted by Josh Rehman <jr...@citysearch.com>.
axisnewbie wrote:
...
> My question is if there is another way or if there is a standard way dealing with optional fields in parameter when Nil, NULL, zero is a valid value.

I am interested in this problem as well.