Hi Roy,

Have you considered using the "Value Object" pattern. Specifically,
you can create a bean which holds the update values and also a set
of booleans indicating which fields to update:

  {
    long ID;
    boolean updateID;

    String name;
    boolean updateName;

    ...
  }

You could also use this (or similar) bean to retrieve all the fields
in a single network call.

I've never done this with Axis, but I believe that Axis' built-in
BeanSerialiser will take care of your Value Object automatically.

Rgds,

Dan.

-----Original Message-----
From: Roy Wood [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2003 16:24
To: [EMAIL PROTECTED]
Subject: Pass null value for parameter? Optional params?


I've got a service that exposes a method to update some values in a 
record.  Rather than several individual methods (setX, setY, setFoo, 
etc.), I'm using a single method that allows the caller to update all 
possible fields in one action (reduces network traffic).  I would like to allow the 
caller to control which parameters are acted upon though, and 
am wondering if anyone has any recommendations in this regard.

For example, consider a method definition something like this:

     UpdateRecord(long ID, String name, int age, String address);


I'd like the user to be able to selectively request updating only the 
name or only the age or perhaps just the age and the address, etc.  And 
remember, I want to minimize traffic, so implementing setName(), 
setAge(), setAddress() is not acceptable.

My current plan is to pass -1 for the numeric values I don't want 
updated, and an empty string for the "String" parameters I don't want 
updated.  I'm fine with the numeric case, but for the Strings, it would 
be nicer to pass null.  Is this possible?

I suppose the other thing I could do is pass some sort of flag(s) 
indicating which parameters are to be acted upon.


Any comments?


-Roy



"Disclaimer � The opinions expressed in this message are strictly 
personal and do not necessarily reflect those of FiLogix." 


***************************************************************************
This communication (including any attachments) contains confidential information.  If 
you are not the intended recipient and you have received this communication in error, 
you should destroy it without copying, disclosing or otherwise using its contents.  
Please notify the sender immediately of the error.

Internet communications are not necessarily secure and may be intercepted or changed 
after they are sent.  Abbey National Treasury Services plc does not accept liability 
for any loss you may suffer as a result of interception or any liability for such 
changes.  If you wish to confirm the origin or content of this communication, please 
contact the sender by using an alternative means of communication.

This communication does not create or modify any contract and, unless otherwise 
stated, is not intended to be contractually binding.

Abbey National Treasury Services plc. Registered Office:  Abbey National House, 2 
Triton Square, Regents Place, London NW1 3AN.  Registered in England under Company 
Registration Number: 2338548.  Regulated by the Financial Services Authority (FSA).
***************************************************************************

Reply via email to