"Craig R. McClanahan" wrote:
>
> On Mon, 12 Mar 2001, Nick Pellow wrote:
>
> > Craig,
> > Is there a reason why the BaseFieldTag does it's processing in
> > doStartTag() and not in doEndTag()?
> >
>
> Probably because I never contemplated a case where an input field tag
> would have a body, so it never seemed to matter. Is there a use case
> where it would make more sense to process the field at the end?
Craig,
Well, there seems to be a lot of questions lately about dynamic forms.
i.e. form elements that are generated at run time
Also, these two items in the TODO1.1 list:
Improved Iteration Support. Improve the ability to use the
<logic:iterate> tag over a
collection, and generate a set of input fields for each member of the
collection (perhaps
auto-generating a subscript?). A significant use case is master-detail
relationships (say, a
customer and their current orders) where you allow editing of any and
all fields.
[STRUTS-USER, Lars, 12/06/2000] [STRUTS-USER, Chandan Kulkarni,
12/26/2000]
and
ActionForms With Dynamic Properties. Create mechanisms to support
ActionForm
implementations where the set of properties to be included is
dynamically calculated, in addition to
the current support for properties that are accessed through the Java
Reflection APIs and are
therefore fixed.
I think if we solved the second one, we could solve the first.
Two solutions I have came up with is to allow the input tags to be
configured, (ie have their attributes set)
at run time. This would require input tags to have a body, (although not
required).
So as not to bore you too much I will cut straight to a syntax example.
<logic:iterate collection="personList" id="element" property="">
<html:text property="personTable">
<html:name>
person<bean:write name="element" property="personName"/>
</html:name>
<html:value>
<bean:write name="element" property="personId"/>
</html:value>
</html:text>
</logic:iterate>
would render:
<input type="text" value="Peter" name="person2"/>
<input type="text" value="Paul" name="person8"/>
<input type="text" value="Mary" name="person23"/>
and would fill the 'personTable' property on the form bean with the
following Map:
[{"person2", "Peter"}, {"person8", "Paul"}, {"person23", "Mary"}]
The internal elements, <html:name> and <html:value>
would simply do a findAncestorWithClass(BaseFieldTag.Class)
and call the setters for both name and value on the BaseFieldClass
passing the values of their body content.
The BaseFieldTag can then render the html tag.
Both the <html:name> and <html:value> tags could be re-used with any
tags that extend BaseFieldTag.
Maybe a more elegant solution in terms of Syntax is to create
an
<html:texts property="personList" labelProperty="personName"
labelName="personId"/>
this behaves in a very similar manor to the <html:options> tag.
Please let me know if you already have a plan to solve these issues on
the
TODO list.
Cheers,
Nick
>
> > Cheers,
> > Nick
> >
>
> Craig