You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bram <br...@info.nl> on 2001/01/28 04:08:10 UTC

Dynamic properties

Hi,

Is there any way to dynamicly add properties to a bean?

The problem is that I have a recordset and want to use the colomn names as a property (indexed) without writing a bean for every possible recordset so I can use it with Struts.

Bram 

Re: Dynamic properties

Posted by Matthias Bauer <Ma...@livinglogic.de>.
Hi there,

this is a very interesting question Bram raised and I would very urgently need
this feature in my current application, too. So I would really like to know if
this can be achieved with Struts. Does anybody know, how a form bean could be
dynamically equipped with properties, so it could be used for multiple forms,
not just a single one?

So what I am looking for are the following two things:

1. The form bean which is associated to a struts form should be instantiated by
a factory which decides depending on a cgi parameter which form bean to use.

2. The form bean can contain indexed properties which are accessed by methods
which conform to the JavaBeans specification, e. g. setter(int index,
PropertyType value).

If I am getting it right, there is currently no way to accomplish this, because
Struts only allows static mapping between the form elements' names and the form
bean elements' names. And you can only define a static mapping from jsp forms to
form beans in struts-config.xml.

I would be glad if I were wrong and it is relly an easy thing to do something
like that. So any suggestions would be very welcome.

Thanks,

--- Matthias

Matthias Bauer +++ mba@livinglogic.de +++ LivingLogic AG +++ www.livinglogic.de


> bram wrote:
> 
> Hi,
> 
> Is there any way to dynamicly add properties to a bean?
> 
> The problem is that I have a recordset and want to use the colomn names as a
> property (indexed) without writing a bean for every possible recordset so I
> can use it with Struts.
> 
> Bram