Bill,
I'm not sure that this satisfies your requirements, but I've built a set of
JavaBean->HTML objects that may be of use to you or someone else.
Instantiate the Bean, set the appropriate values (name, value, selected
item) and print. Afterward I found SPFC & ECS from java.apache.org, my
Beans are similar yet different.
It may be easier to see what I mean than listen to me try to explain it.
http://www.brainopolis.com/jsp/
Lance Lavandowska
www.AgDomain.com
www.Brainopolis.com
----- Original Message -----
From: "Bill White" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 20, 2000 9:15 PM
Subject: SELECT lists?
> Ok, let us see who is creative out there:
>
> Who has come up with an ingenious way to populate SELECT input list boxes
> with JSP, JavaBeans and/or JDBC?
>
> I'm just looking for better ways to do this.
>
> Right now, I have a page that provides a <SELECT> list containing the
names
> of people, using their ID numbers as identifiers. I have built a
> "ListBean" object, which is capable of returning a LinkedList object
> containing several "SelectListItem" objects. The "SelectListItem" object
> contains two properties: index and value. This is so I can mimic the
> format of the html <SELECT> list options, which have an index and a
visible
> value for each <OPTION> in the <SELECT> list.
>
> I create a "ListBean", call the getNameList() method (passing a SQL
> statement) and the use JSP to loop through the returned LinkedList,
> grabbing each "SelectListItem" and adding its properties to my <SELECT>
> list <OPTION> items. I've listed this JSP code below in case you would
> like to see it.
>
> Now this works great, but I know there has got to be a more ingenious way
> to do this type of thing. I'm sure I could have done it in half the code
> and made it twice as simple, but I'm not a real Java guru yet, so I'd love
> to hear how others of you have done this type of thing.
>
> Regards,
> bill
> [EMAIL PROTECTED]
>
> Here's the code:
>
> <jsp:useBean id="item" scope="request" class="winston.ListBean"/>
>
> <%!
> LinkedList linkList;
> SelectListItem selItem;
> int i;
> %>
>
> <%
> linkList=item.getNameList("Select PersonID, LastName, FirstName,
MiddleName
> from People Order By LastName");
> %>
>
> <SELECT name="mylist">
> <%
> for(i=1;i<linkList.size();i++)
> {
> selItem=(SelectListItem)linkList.get(i);
> %>
> <option value=<%=selItem.getItemIndex() %>><%=selItem.getItemValue() %>
> <%
> }
> %>
> </SELECT>
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html