|
hi,
<html:select > works best with a collection of
dataobjects.
use
<html:select property="sdf">
<html:optionsCollection property="arrList"/>
</html:select >
here arrList could be arraylist of name value pairs,
something like
ArrayList arrList = new ArrayList();
arrList.put(new LabelValueBean("label","value"));
arrList.put(new LabelValueBean("label1","value2"));
arrList.put(new LabelValueBean("label2","value2"));
LabelValueBean class is provided by struts
AFAI hashtable does't fit in here.
u will have to iterate thro' the hashtable , if u want to still use
the hashmap
or go by arraylist to make things easier
--nagendra
-------Original Message-------
Date: Friday, June 06,
2003 05:23:19 PM
Subject: doubt with
dropdown list box
hi, I'm a newbie to STRUTS. I have a doubt in
pre-populating a dropdown listbox in Struts ..while loading the JSP
itslef the listbox has to be populated. I have a JavaBean wich has a
method called getDetailsinHt() which is returning hashtable its
something like this- ht.put((new Long(LoginId )),sDetails); sDetails is
a String array - String[] sDetails = new String[4]; this string array
contains first,middle and last names How canI do this.I havebeen doing
this since hours but in vain..:( someody plez help me.
The code
is like this:
Test { public Test{}
public long
id; public String name[];
public long getId() { return
(id); }
public void setId(long id) { this.id =
id; }
public String[] getNames() { return
this.name; }
public void setName(String[] name) { this.name =
name; } public Hashtable getDetailsinHt() { Hashtable ht=new
Hashtable(); String[] sDetails = new String[4]; sDetails[0] =
"Name"; sDetails[1] = "Name"; sDetails[2] = "Name"; ht.put((new
Long(LoginId )),sDetails); return ht; } }
in my
ActionForm I'm writing theget andset methods like
public Hashtable
getUserId() { return userId;
public void setUserId(Hashtable
userId) { this.userId= userId; }
public Hashtable
getList() { UserList iab=new UserList(); try { Hashtable
users=iab.getUserList(0); }catch(Exception e){} return
users; }
and in my JSP I'm giving as <bean:define
id="list" name="createIssueForm"
property="userId" type="java.util.Hashtable"/> <html:select
property="users" size="1"> <html:options collection="list"
property="id" labelProperty="name"/> </html:select> but
I'm not able to populate the list box.....here I guess I'm
doing something wrong with the ------ property="id"
labelProperty="name"/>
Can somebodt plez tellme where I'm
wrong?? Thanx
--------------------------------------------------------------------- To
unsubscribe, e-mail: [EMAIL PROTECTED] For
additional commands, e-mail: [EMAIL PROTECTED]
. |