Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Struts
DropDown Menu error in Struts 2
Dushyant Chhetri
Ranch Hand
Posts: 75
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
I am trying to create a dropdown menu on using struts2 .
I am implementing the UI on
jsp
with
struts
taglib.
Now I want to populate the data on the dropdown froma database.
For this I have used the following and created an arraylist
<s:form action="IssueItems"> <%Connection con=DBDriverConn.getConnection(); Statement st=con.createStatement(); ResultSet r1=st.executeQuery("select * from hardware_list "); %> <%List<String> hardwarelist= new ArrayList<String>(); while(r1.next()){ hardwarelist.add(r1.getString(1));} %> <%System.out.println("list size is "+hardwarelist.size()); for(int i= 0; i < (hardwarelist.size());i++){ System.out.println("Item "+i+" "+hardwarelist.get(i)); } %> <h4> <s:select label="Select Hardware" headerKey="-1" headerValue="Select Device" list="hardwarelist" //commenetd *Using this gives result list="#{'1':'Jan', '2':'Feb', '3':'Mar', '4':'Apr'}" name="selectedDevice"/> </h4> <s:submit value="submit" name="submit" /> </s:form>
The action for the above submit form is
package com.model; import com.opensymphony.xwork2.ActionSupport; public class IssueItems extends ActionSupport{ private String selectedDevice; public String execute() { return SUCCESS; } public String issue(){ System.out.println("in issue method "); System.out.println("here "+getSelectedDevice()); return new String("issued"); } public String getSelectedDevice() { return selectedDevice; } public void setSelectedDevice(String selectedDevice) { this.selectedDevice = selectedDevice; } }
However I am getting the following error
Oct 22, 2011 4:45:06 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception tag 'select', field 'list', name 'selectedDevice': The requested list key 'hardwarelist' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] at org.apache.struts2.components.Component.fieldError(Component.java:231)
Please suggest me where I am going wrong.
Sunil Sunny
Ranch Hand
Posts: 42
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
you must first delete the name attribute. and then check if you get some value in drop down then tell me
I promise I will be the best, most loyal friend ever! All for this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Need to know if I am doing this right or not
Dropdown creation dynamically from DB lookup
s:select Error The requested list key 'encoder' could not be resolved as a collection
HTTP Status 404 - /Struts2Application1/clientAction + Please help
Struts2 newB: some simple questions
More...