Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

LinkedHashMap Iteration problems  RSS feed

 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a LinkedHashMap to hold all of the US States and their abbreviations.
My problem is that I want to access them from a JSP to iterate through in a drop down list but I keep getting the following error:

javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items"

Here is a snippet of the LinkedHashMap Code:



Here is a snippet of the JSP Code:



Thanks in advance for your help!

Chris Cornelius
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to iterate over StateMap which



is not a collection.

If it's the underlying public static map instance you want to iterate over, you must reference it, not the containing class.
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

I have made the changes but now get this error:

javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "items" with value "${ListOfStates.stateMap}": Unable to find a value for "stateMap" in object of class "com.rxamerica.enrollment.util.StateMap" using operator "." (null)

Here are the changes:



What am I missing?

Chris
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to study up on the EL a bit. You are trying to access a static field of the class. The EL can only access properties of classes that are established as scoped variables.

In other words. you need to provide a property accessor (getter) for the collection element.
[ December 01, 2005: Message edited by: Bear Bibeault ]
 
Chris Cornelius
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will do, thanks!

Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!