Re: Need help with beans - adding properties at run time???
From: Chris Smith (cdsmith_at_twu.net)
Date: Mon, 19 Apr 2004 08:10:50 -0600
Nikita A. Visnevski wrote:
> Well, from what I read so far it seams that I have to have a getXXX and
> setXXX method defined in my wrapper class for every property I want to
> inspect. I can not define these methods since I have no idea what
> properties the user might add to my original object. Is there any way
> to work around this difficulty?
In the end, you'll have to provide a pair of accessor/mutator methods
for each property. You don't have to call them setXXX and getXXX is you
don't want to (see BeanInfo for an alternate way to specify these
methods if they have different names), but you do need for them to
One way around this, if you're very determined, may be for you to
generate a JavaBeans wrapper class around your original table-like
object. You'd need to do some Java code generation, and BCEL would be
very helpful in accomplishing this. Essentially, you'd want to generate
a class whose objects hold a reference to your original object and
expose a set of methods that look like JavaBeans methods. These methods
would pass their operations through to your original object. You'd need
to generate the bean class and object on the fly whenever you want to
inspect the data as if it were a JavaBean.
-- www.designacourse.com The Easiest Way to Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation