You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Michael Gerdau <mg...@technosis.de> on 2001/08/11 15:58:53 UTC

Q/Suggestion: ActionForms With Dynamic Properties

Hi list/Craig !

I'm in desperate need of Dynamic Properties in ActionForms. Apparently
it already is on the TODO liust for 1.1 but does not yet has a volunteer
assigned.

Therefor I have had a look as to how they possibly could be implemented.
I'll give a quick overview of how I think they could be implemented and
would like your comments wether
- that would work
- that would fit into struts (aka not break other stuff)
- it would make sense if I'd write and contribute code to do that

Of course any other remarks are welcome as well.

If I understand the current mechanism correctly the function
org.apache.struts.uril.RequestUtils.populate(...)
is responsible to read out the HTML form submitted by the browser.

There the problem is that only one bean is known (the ActionForm) and
everything we could do with Reflection refers to that bean. However
when rendering data using various struts tags (incl. logic:iterate)
we access other beans as well. If we could remember somehow preserve
the info which field corresponds to which bean then the existing
mechanism could be used with almost no changes.

The following tries to roughly describe how the above could be achieved.

When rendering a <html:text> tag in the servlet one would have to
create a hash of all beans involved in a particular form possibly
including the ActionForm itself as well. Each such bean would receive
a unique key (the hash key - possibly just linear numbering and avoiding
different references to the same bean though it would even work with) and
get stored class info and a reference to the object itself.

When rendering the name of the field this could be prepended by the
hash key and a separator thus allowing to retrieve it later in
RequestUtils.populate(...)

Last not least we'd only need a means to save and retrieve the hash.
Ideally this would be an instance variable of the ActionForm but I'm
not sure of the impact on other areas (e.g. serializeability) - however
hopefully this is a solveable problem.

Comments ?

Best,
Michael
--
 Vote against SPAM - see http://www.politik-digital.de/spam/
 Michael Gerdau       email: mgd@technosis.de
 Defrustration for the 90's -- throwing Windows out!
 PGP-keys available on request or at public keyserver