You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Srilatha <sr...@edstechnologies.com> on 2003/06/06 13:52:04 UTC

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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: doubt with dropdown list box

Posted by Srilatha <sr...@edstechnologies.com>.
hey,
nobody uses Hashtables in in Struts?????Its a wonder really


-----Original Message-----
From: Srilatha [mailto:srilatha.blr@edstechnologies.com]
Sent: Friday, June 06, 2003 6:04 PM
To: Struts Users Mailing List; Nagendra Kumar O V S
Subject: RE: doubt with dropdown list box


The problem here is I need to use Hashtables only bcoz most of my routines
are returning Hashtables
I dont know exactly but is it possible thru <logic:iterate> ??how can I do
this...

-----Original Message-----
From: Nagendra Kumar O V S [mailto:nagendra@ikigo.com]
Sent: Friday, June 06, 2003 5:46 PM
To: struts-user@jakarta.apache.org
Subject: Re: doubt with dropdown list box



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-------

From: Struts Users Mailing List
Date: Friday, June 06, 2003 05:23:19 PM
To: struts-user@jakarta.apache.org
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


.


____________________________________________________
  IncrediMail - Email has finally evolved - Click Here


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


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


RE: doubt with dropdown list box

Posted by Srilatha <sr...@edstechnologies.com>.
The problem here is I need to use Hashtables only bcoz most of my routines
are returning Hashtables
I dont know exactly but is it possible thru <logic:iterate> ??how can I do
this...

-----Original Message-----
From: Nagendra Kumar O V S [mailto:nagendra@ikigo.com]
Sent: Friday, June 06, 2003 5:46 PM
To: struts-user@jakarta.apache.org
Subject: Re: doubt with dropdown list box



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-------

From: Struts Users Mailing List
Date: Friday, June 06, 2003 05:23:19 PM
To: struts-user@jakarta.apache.org
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


.


____________________________________________________
  IncrediMail - Email has finally evolved - Click Here


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


Re: doubt with dropdown list box

Posted by Nagendra Kumar O V S <na...@ikigo.com>.
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-------

From: Struts Users Mailing List
Date: Friday, June 06, 2003 05:23:19 PM
To: struts-user@jakarta.apache.org
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


.