• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing only the updates to objects

 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am currently working on an application where in I have to communicate to web services. We have used xmlbeans to create the java wrapper classes for these webservices exposed functionality.
All scenarios pertain to create and updates. Creates are fine where in I set all the values from our business objects to the xmlbeans representative objects of webservices and pass it on.
For updates I wanted to know if there are any good practices available which I can use. What I want to do is compare the fetched object with changes made by user at the front end. This determination can be carried by using equals method. We plan to override the equals method in our business objects.
Now the second part of passing only the changes. Now while calling the webservice I want to assemble the input objects only with changed attributes.
I am wondering how best can I handle this rather than using if-else constructs.

Do post your thoughts on the same


~Manish
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am I reading you right ... you want an object with only the fields that changed populated? That would generate XML with only the tags that changed?

I can imagine using reflection or something in bean utils to call each public getter on two instances of the same class and call set on a third instance only if the results are not the same.

As a non-standard alternative, you might make all the setters track "dirty bits" to indicate which fields have changed. I'm working with a framework now that does that. I think they load an object, clear all the dirty bits, then apply changes from the user which sets new dirty bits.

Every once in a great while I miss PowerBuilder. This stuff was all built in. Sigh.
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stan James,

Thanks for your response.

----------------------
Am I reading you right ... you want an object with only the fields that changed populated? That would generate XML with only the tags that changed?
----------------------
Yes this is exactly what I want to achieve.

----------------
As a non-standard alternative, you might make all the setters track "dirty bits" to indicate which fields have changed. I'm working with a framework now that does that. I think they load an object, clear all the dirty bits, then apply changes from the user which sets new dirty bits.
----------------
Can you elaborate a bit more on "all setters track dirty bits". I did not get this from an implementation perspective. This alternative sounds apt for the scenario I am working on.


Thanks & Regards,
Manish
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stan,

Could you provide a few hints on the same.

Thanks in advance.

Manish
reply
    Bookmark Topic Watch Topic
  • New Topic