Results 1 to 2 of 2
- 02-12-2008, 08:02 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 2
- Rep Power
- 0
How to use a drop-down box in Struts
If anyone can help me how to show the List values in a drop-down box, that would be greate.
I have created a List in Action class and put it into request
ArrayList list = new ArrayList();
list.add("1");
list.add("2");
request.setAttribute("exsList", list);
And in JSP I have following:
<bean:define id="aList" name = "exsList" />
I just want to display these numbers in drop-down. What should I do next. Thank you
- 02-13-2008, 11:42 AM #2
Member
- Join Date
- Nov 2007
- Posts
- 15
- Rep Power
- 0
Hi ,
on jsp use this code
<html:select property="contact" >
<html: optionsCollection property="listOfContact" >
</html:select>
Now in ActionForm (bean which form is using)write setter and getter for String "contact" and List "listOfContact".
after in constuctor of ActionForm write logic=
public constuctorName() {
listOfContact=new ArrayList();
listOfContact.add(new LabelValueBean("1","Printing media"));
listOfContact.add(new LabelValueBean("2","Radio"));
listOfContact.add(new LabelValueBean("3","T.V."));
}
u have to import package:
import org.apache.struts.util.LabelValueBean;
when u run jsp list will come on page.;)Last edited by Poonam; 02-13-2008 at 11:44 AM.
Similar Threads
-
Drop down menu
By BenNeiderlander in forum New To JavaReplies: 3Last Post: 02-05-2008, 07:35 AM -
Drag and drop
By abhivenugopal in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 01-30-2008, 02:10 PM -
help drag and drop in JTabbedPane
By RO86 in forum AWT / SwingReplies: 0Last Post: 08-14-2007, 01:22 PM -
drop down box details info
By eeau1973 in forum New To JavaReplies: 0Last Post: 08-11-2007, 09:04 PM -
Is it possible to disable drop in a component?
By Ada in forum AWT / SwingReplies: 3Last Post: 06-07-2007, 05:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks