• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select Tag error in struts2

 
Sirisha Gundelli
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sirisha Gundelli
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And do you have a publicly-accessible getter for countries?
 
Sirisha Gundelli
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

Its working fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic