You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ra...@iflexsolutions.com on 2004/05/15 14:43:28 UTC

 
What I have:

My DB class returns me following arraylist that I store in request, Pls
see the code below for the Structure

private ArrayList dummyList() {
	ArrayList row = new ArrayList();
	ArrayList data = new ArrayList();

	for(int jk=0; jk<5;jk++){
		row = new ArrayList();
		row.add(new Integer(jk)); 
		row.add("TEXT"+jk);
		data.add(row);
	}
	return data;
}
Here I have an arrayList which itself has an arraylist with two elements

My Problem:
How can I iterate it to show the it in <html:options ??? What name I
will provide to iterate it to 
Give Integer element as "value" field and String field as "shown value"

Pls provide some example


Thanks for your time..

raman




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


Re: Posted by "Domingo A. Rodriguez S." <do...@yahoo.com>.
Use html:options collection="dummyList" labelName="key"
labelProperty="value" 

Implement this javabean..

public class Row implements java.io.Serializable{ 
  Row(String key, String value){this.key=key;this.value=value;};
  private String key="";
  private String value="";
  public String getKey(){return key;};
  public String getValue(){return value;};
  public void setKey(String key){this.key= key;};
  public void setValue(String value){this.value= value;};
}

> private ArrayList dummyList() {
> 	ArrayList data = new ArrayList();
> 	for(int jk=0; jk<5; jk++){
> 	    data.add( new Row(jk+"", "TEXT"+jk) );
> 	}
> 	return data;
> }


 --- Raman.garg@iflexsolutions.com escribió: >  
> What I have:
> 
> My DB class returns me following arraylist that I store in request, Pls
> see the code below for the Structure
> 
> private ArrayList dummyList() {
> 	ArrayList row = new ArrayList();
> 	ArrayList data = new ArrayList();
> 
> 	for(int jk=0; jk<5;jk++){
> 		row = new ArrayList();
> 		row.add(new Integer(jk)); 
> 		row.add("TEXT"+jk);
> 		data.add(row);
> 	}
> 	return data;
> }
> Here I have an arrayList which itself has an arraylist with two elements
> 
> My Problem:
> How can I iterate it to show the it in <html:options ??? What name I
> will provide to iterate it to 
> Give Integer element as "value" field and String field as "shown value"
> 
> Pls provide some example
> 
> 
> Thanks for your time..
> 
> raman
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>  

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

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


R: Posted by Andrea M <an...@fastwebnet.it>.
Hi Raman
I would rather suggest you to put in your scope an ArrayList of beans, each
one eventually with getName() and getLabel()  (or whatever you like)

So.. in that case, if your collection is stored as "dummyList" then you
could access it like this:
<html:options collection=" dummyList" property="name"
labelProperty="label"/>

Where property attribute will be the value (and the property you will
eventually set in your actionform) and labelProperty will be the text
displayed


Another chance if you don't want make a javabean of your own is to use a
HashMap. In that case it will be the same, except that you will have to use
"key" and "value".
e.g:
<%
   java.util.HashMap myMap = new java.util.HashMap();
   myMap.put("TEXT1", "1");
   myMap.put("TEXT2", "2");
   session.setAttribute("myMap", myMap);
%>

<html:options collection="myMap" property="value" labelProperty="key"/>



-----Messaggio originale-----
Da: Raman.garg@iflexsolutions.com [mailto:Raman.garg@iflexsolutions.com] 
Inviato: sabato 15 maggio 2004 14.43
A: struts-user@jakarta.apache.org
Oggetto: <html:options

 
What I have:

My DB class returns me following arraylist that I store in request, Pls
see the code below for the Structure

private ArrayList dummyList() {
	ArrayList row = new ArrayList();
	ArrayList data = new ArrayList();

	for(int jk=0; jk<5;jk++){
		row = new ArrayList();
		row.add(new Integer(jk)); 
		row.add("TEXT"+jk);
		data.add(row);
	}
	return data;
}
Here I have an arrayList which itself has an arraylist with two elements

My Problem:
How can I iterate it to show the it in <html:options ??? What name I
will provide to iterate it to 
Give Integer element as "value" field and String field as "shown value"

Pls provide some example


Thanks for your time..

raman




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


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