If you have a collection of, say, JavaBeans, that you've set on the
request, you can use <c:forEach> to iterate over each of the beans in
the collection and generate your checkbox, select list, and text field
dynamically for each of the entries in the collection.
I.e., let's say in my action, I've set a attribute on the request called
"foo" which is a collection of "BarBeans." Then you would say:
<c:forEach var="aBarBean" varStatus="status" items="${foo}">
your code here...
</c:forEach>
The variable "aBarBean" represents the BarBean instance currently being
iterated over in the collection. You would then use ${aBarBean.XXX} to
call your bean methods where XXX represents the getter method in the
bean (sans "get" and appropriately camel-cased).
-Adam
Yanroy wrote:
Hello again,
I've found plenty of examples online for how to create dynamic sets of
checkboxes and radio buttons (and I've put them to good use), but I need to
also dynamically create select and text fields. I managed the text field by
coding the HTML for it by hand, since I don't need to pre-populate a value
from the struts form. I can't figure out how to do something similar for
the select, however. I need the struts <html:options> tag to generate the
options, but for some reason it refuses to be used without being inside an
<html:select>. Is there a way I can trick <html:select> into providing
multiple, dynamically generated select fields?
For an example of what I'm trying to create, consider this: I want a form to
set up email notifications for a number of events. I pass the names of the
events forward from my strut as an array in the request. For each event, I
want to generate a check box (to indicate whether or not I want to be
notified), a select field (to indicate a type of comparison such as "less
than" or "greather than"), and a text field (to input a threshold value).
I can't find anything about this with google, and a search of this forum
only yielded one post from January that didn't have any replies. I hope
someone here will be kind enough to let me know if this is possible and if
so, how to do it.
Thanks,
Ryan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]