Hi Stefan
I think this is how u should do it

<bean:define  name="YourFormName"     id="names"
property="nameArrayList" />
<html:select property="selectedName">
<html:options collection="names"     property="value"
labelProperty="label" />
</html:options>


Here retrieve the names in your Action class using -ArrayList getAllNames().
Set that ArrayList to your ActionForm . Then in Jsp file use <html:select>
amd <html:options> tag  to show those Names present in  your ActionForm as
ArrayList

Here create <bean:define> tag which will expose ur ArrayList present in the
ActionForm as a scripting variable - "names"
Then give that as the collection attibute value to <html:options >  tag .
Here  U need to mention the value and labelProperty attributes.

I mean the ArrayList contains the objects say - NameLabelValue  And in that
have getter "value" and " label" methods
like
Class  NameLabelValue implements Serializable {
       private String name;
    public String getValue( ) {
        return name;            // this will displayed in the drop down list
as option
    }
    public String getLabel() {
        return name;        //  this is label corresponding to above option
which will be send to server when u select a option
    }
}
So basically the ArrayList  called "nameArrayList" present in your
ActionForm should contain objects of above classes .

Please contact me if u need any help in this
Suhas


----- Original Message -----
From: Stefan Faist <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 10:19 AM
Subject: Problems with select ans iterate


When I start the site, I get the fallowing error message:
"Cannot find bean mitarbeiter in scope null"

The code I wrote is:
<select name="select" size="7" class="textbox">
<logic:iterate id="mitarbeiter" name="allMitarbeiter" >
<option><bean:write name="mitarbeiter" property="value"/></option>
</logic:iterate>
</select>

The JSP-Site has the name verwaltung.jsp and allMitarbeiter is an Attribute
in the VerwaltungForm.java and in this file there is an getAllMitarbeiter()
methode which returns a ArrayList. This ArrayList includes some Strings.
How can I do this?
I hope someone can help me

Stefan

> -----Ursprüngliche Nachricht-----
> Von: Jorrin Ruiz de Arcaute, Jorge [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 9. Juli 2001 10:13
> An: [EMAIL PROTECTED]
> Betreff: RE: html:option & html:select
>
>
> Try:
>
>                     <select name="select" size="7" class="textbox">
>
>                       <logic:iterate id="modelo" name="listado">
>
> <option>
> <bean:write name="modelo"
> property="imagen"/>
> </option>
>
>       </logic:iterate>
>
>                     </select>
>
> Listado is a session Constant that's loaded at the Action.
> Good Luck!
>
> > -----Mensaje original-----
> > De: Stefan Faist [SMTP:[EMAIL PROTECTED]]
> > Enviado el: lunes 9 de julio de 2001 8:55
> > Para: Struts
> > Asunto: html:option & html:select
> >
> > Hi,
> > I have mySQL Database and the data-source I have defined in the
> > struts-config.html.
> > In a JSP-site I want to access to this database with an methode like
> > "ArrayList getAllNames()" and this list I want to put in a dropdown menu
> > with the <html:option> & <html:select> Tags, but how can I get this
> > array-list for my jsp-site? How can I call this methode?
> >
> > Best regards,
> > Stefan Faist
> > ----------------------------------------------
> > hmi-Informatik GmbH
> > Zettachring 6 - D-70567 Stuttgart
> > E-Mail: [EMAIL PROTECTED]
> > http://www.hmi-informatik.de
>
>

Reply via email to