my dog learned polymorphism*
The moose likes Struts and the fly likes Select Tag error in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Select Tag error in struts2" Watch "Select Tag error in struts2" New topic
Author

Select Tag error in struts2

Sirisha Gundelli
Greenhorn

Joined: Jul 23, 2009
Posts: 3
Hi,

I am using select tag to display list of countries in a jsp. But when i run the application it is giving me the below error.

tag 'select', field 'list', name 'country': The requested list key 'countries' could not be resolved as a collection/array/map/enumeration/iterator type.

<s:select
name="country"
label="Country"
list="countries"
emptyOption="true"
headerKey="0"
headerValue="Please Select"
listKey="key"
listValue="description"/>

Please help me out.

Thanks
Sirisha
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
In plain English - 'countries' must be a collection of objects. These objects would be String(s) - names of countries, in your case. Please check if this is the case. Also check the scope of 'countries'

Regards


Experience and talent are independent of age
Sirisha Gundelli
Greenhorn

Joined: Jul 23, 2009
Posts: 3
Thanks Himanshu for your reply.

private Collection<CountryNames> countries = new ArrayList<CountryNames>();

countries.add(new CountryNames(1,"US"));
countries.add(new CountryNames(2,"India"));
countries.add(new CountryNames(3,"Canada"));

This is the way I have populated the countries in my action class.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And do you have a publicly-accessible getter for countries?
Sirisha Gundelli
Greenhorn

Joined: Jul 23, 2009
Posts: 3
Thanks.

Its working fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Select Tag error in struts2
 
Similar Threads
How to fill up JSONArray data inside the select tag of JSP Page
how to populate a list in a another select tag using a select tag using struts 2 & DOJO (ajax)
Struts2 label tag - key attribute is being replaced with actual value?
Populating dropdown menu based on another
How to display a list box with values from an "Array List" in "Struts2"