See comments:
Jim Preston wrote:
>
> A question for experienced JSP/bean developers:
>
> It seems to me that a common task in a JSP is to output a list of some sort
> where the contents and length of the list are variable and obtained from a
> bean (for example, when creating a pull-down menu of dynamic options).
Yup. Over and over again.
> And
> from what I've read, there's no automatic way to do that (by automatic
> I mean something akin to "jsp:getProperty"). So it has to be programmed,
> having the bean return an array or an Enumeration (etc.), and then using
> a scriplet to loop through the elements.
>
> But for the same reasons that "jsp:getProperty" is preferred over using
> an expression tag to access the bean's "get" method directly, I would
> think that there'd be something similar for looping through dynamic lists.
>
It depends on what JSP spec you are able to use, but we have got round
some of the problems by using JSP 1.1, which allows you to write custom
tag libraries.
this allows you to write tags to deal with things like an Enumeration,
or a Java 2 Collection and Iterator. If you get the objects sequentially
out of a collection, you can then place them into Page scope, and allow
the <jsp:useBean ... /> tag to be used normally within the custom tag.
Basically you then get a repeating section of JSP script, repeated for
each object in a collection.
Don't see how else you do it unless you want to start writing specific
html aware tags like "mytag:doTable " or "mytag:doSelect" etc.
(and damn I wish I'd blagged a visit to Java One... :( )
--
Jari Worsley
Senior Programmer
Hyperlink plc
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets