I posted this question a couple of days ago and received an answer.
Unfortunately the answer does not work for me.  The problem I am having is
on the initial page of my web application I have drop-down boxes that I
want to be populated with information from a database.  I have no problem
getting the recordset but do not know how to transfer that recordset data
into the drop-downs.  I was able to populate the drop-downs similar to the
example used in the documentation but that does not have  an example of how
to populate them with live data.  Can anyone give me a quick lesson on how
to do this.
Tim Bachta
Information Technology
MC 48
816-997-7137


                                                                                       
                                          
                      Eddie Bush                                                       
                                          
                      <[EMAIL PROTECTED]        To:       Struts Users Mailing List 
<[EMAIL PROTECTED]>              
                      t>                       cc:                                     
                                          
                                               Subject:  Re: select and option tag 
issues                                        
                      11/06/2002 11:52                                                 
                                          
                      AM                                                               
                                          
                      Please respond to                                                
                                          
                      "Struts Users                                                    
                                          
                      Mailing List"                                                    
                                          
                                                                                       
                                          
                                                                                       
                                          




Have you discovered the collection attribute of the options tag?  Your
action can build any collection you desire (ie from a database -- see
org.apache.struts.util.LabelValueBean for holding the name/value pairs).
 It then places that collection into some scope (whichever you like) and
forwards to the page.  Now, by specifying the key you used when placing
the collection into scope as the value to the collection attribute of
the options tag, you've got a dynamic drop-down populated from the
database.

------------- in your Action subclass

Collection c = ...;

while (...)
{
    String label = ...;
    String value = ...;
    c.add(new LabelValueBean(label, value));
}

request.setAttribute("myCollection", c);

------------- in your JSP

<html:select ... >
    <html:options collection="c" ... />
</html:select>

(This isn't in the FAQ, is it?  <goes-to-check/>)

[EMAIL PROTECTED] wrote:

>Hi all,
>
>I am very new to struts and I am trying to create combo boxes using the
><html:select><html:options> tags.  I have been able to create and populate
>them with string arrays placed on the JSP page similar to the examples in
>the documentation.  What I really need to do is populate them based on
>information in a database.  I can create the recordset but after that I am
>lost.  Can anyone please help.  Thank you.
>Tim Bachta
>
>Tim Bachta
>

--
Eddie Bush





--
To unsubscribe, e-mail:   <
mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <
mailto:struts-user-help@;jakarta.apache.org>







--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to