Robert Taylor wrote:
I've been through the examples included in the struts0.5
release. Specifically I'm looking for examples of using the
select element with dynamically generated options. I
have seen the options element and read its definition but still
am unclear on how to use it.
I, too, found the documentation inadequate in this
area. However, the question has apparently been brought up on this
listserv before. There are examples in the listserv archive.
The fundamental idea is the same as is used for the "User Database" in the
Example example.
Have a look at http://marc.theaimsgroup.com/
Its a searchable Mail ARChive (MARC) covering this listserv (and lots of other
interesting ones too). Just search on "options" for
struts-user.
The thread "Need some help please" explores the use of the
options tag. (The "Subject" text here could use some help!
But, Hey, the same goesfor "More HTML element examples".)
Continuing... The "Need some ... "thread is slightly
misleading. It has examples that use the struts:enumerate
tag. I believe that that tag has now been replaced by
logic:iterate, a switch which undoubtedly contributes to the confusion
on this topic.
Also,have a look at the"Options Tag" thread (Yes,
good Subject text here), but some indications inthat thread that there are
existing bugs in indexed array accesses. (??)
Ted H's reply on the "Need some.." thread indicates that
a Struts "collection" shouldbe synthesized from a "database."
Maybe, maybe not. I can see that a "static" collection, which is often we
really want,would be better derived from a Properties file. However,
in either case, the preferred methodin Struts forinstantiating such
a collection(for usewith html:iterate) is tohave an
made-to-purpose application Servlet which you code up todo the"heavy
lifting".Thecollectionget instantiatedinthat
Servlet'sinit method, when the application is loaded into the server
container. Bottom line, you roll your own. See
"DatabaseServlet.java" in the Example app, for an example.
If you are reading Hans Bergten's book on JSPs,
whichdiscusses a Struts-like architecture,you might naively assume
that the Struts built-in ActionServlet would contain some packaged support for
cons-ing up your collections for you. Not in Rev 1.0 by what I see.
I don't see it on theRev 1.1 ToDo list either, although "Better Database
Support"could be stretched in that direction. Maybe, in that
case,we should be looking at better J2EE Support instead. (IMHO
Application Scope Bean collections are not at all the same thing as Persistent
EJB collections, which iswhere "databases" really fit in. Just my
opinion.)
OK. OK. I'm rambling.
html:options isn't the only area where coding examples
that use (ordered) collectionsunder Struts would be helpful. Has
anyone got an example of Previous
andNextsubmitbuttonsto scan over a
collection for FormBeans? That should be simple, and nice.
Better yet, how about an example of
anIE5.5-styleFloating Popup containing a scrolling list of FormBean
idsthat would dynamically update of the parent page when clicked
...? OK. I'm still rambling. And futuring.
(Except that it should be possible to do a very sweet, veryMVC Floating
Popup now, with Struts 1.0,if you limit yourself to IE5.5)
Dan Connelly
South Burlington, Vermont