• 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

Creating an object using beanutils

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am experimenting with Apache commons beanutils. Now i can copy an entire object using



or I can set any specified instance variable by



The problem i am facing is that I don't have the structure of sourceObject. It can vary at run time. Is there any api in Apache common BeanUtils so that i can make an object same as of sourceObject.

Thanks in advance.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be careful with this BeanUtil thing, Manu. It's meant to be used in frameworks such as Struts, where a large degree of flexibility is needed to make it useful for wide variety of applications. If you start using BeanUtils directly in regular code, you may be subjecting yourself and others to the dangers of unnecessary complexity. (I know, it's about Ruby but the same principles apply in any language, including Java)

That said, you don't need BeanUtils to make an object that's the same as sourceObject. Java already gives you the ability to create clones (Hint: search for 'clone')
 
Manu Somasekhar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Junilu. I got your point.
reply
    Bookmark Topic Watch Topic
  • New Topic