You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Roshan Paiva <Ro...@eRunway.com> on 2001/07/16 14:12:14 UTC

Dynamic Attributes

Hi Everyone...

I have a jsp page which dynamically populates fields ( eg: at one instance
there may be 5 edit boxes and at another instance there may be 3 edit boxes
and a date picker etc. ) The number of fields and there types are not
static. We have currently implemented this without the strut framework
usings Vectors and Collection objects. 

We are now in the process of restructuring the app using struts.. How are we
to create the ActionForm as the number of properties and their types are
dynamic.

Any answers?

Thanks in advance...

Kind Regards
Roshan


Re: Dynamic Attributes

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

as far as I know there is currently no such thing as dynamic form attributes, 
since you need a form bean associated with the action mapping.

If you have a limited number of properties you can put them all in the form bean 
and use only those currently needed. If this is not flexible enough, you have to 
go without the struts support in this respect.

I had to do this myself in my current project. What I came up with is: I have an 
object (stored in the user's session) which contains attribute objects that know 
how to populate themselves from the request. So what I do is: For each attribute 
object I call the method setValueFromRequest(). They can now look for the right 
value(s) in the request and set their internal value(s) as appropriate (and do 
error checks as well).

I think someone is working on dynamic properties to include it in the struts 
framework, though I am not sure.

--- Matthias



Roshan Paiva wrote:

> Hi Everyone...
> 
> I have a jsp page which dynamically populates fields ( eg: at one instance
> there may be 5 edit boxes and at another instance there may be 3 edit boxes
> and a date picker etc. ) The number of fields and there types are not
> static. We have currently implemented this without the strut framework
> usings Vectors and Collection objects. 
> 
> We are now in the process of restructuring the app using struts.. How are we
> to create the ActionForm as the number of properties and their types are
> dynamic.
> 
> Any answers?
> 
> Thanks in advance...
> 
> Kind Regards
> Roshan
>