Dashboard > WebWork 1 > WebWork CookBook > Iterating over a Map
  WebWork 1 Log In View a printable version of the current page.  
  Iterating over a Map
Added by Francisco Hernandez, last edited by Hani Suleiman on Apr 25, 2004  (view change)
Labels: 
(None)

Try this for JSP:

<ww:iterator value="states">
   key=<ww:property value="key"/>, value=<ww:property value="value"/><br>
</ww:iterator>

or for Velocity:

#foreach ($entry in $states.entrySet())
  key= $entry.key, value=$entry.value<br>
#end

To iterate over the error map in a JSP:

<ww:iterator value="errors">
   key=<ww:property value="key"/>, value=<ww:property value="value"/><br>
</ww:iterator>

Using Velocity :

#foreach( $entry in yourMap.entrySet() )
    key=$entry.key, value:$entry.value<br>
#end
Posted by Anonymous at Dec 10, 2002 08:35 | Permalink

I couldnt find this relation of errorMap to errors but if you want to iterate through the errorMap in a jsp you can do it as such:

<ww:iterator value="errors">
   key=<ww:property value="key"/>, value=<ww:property value="value"/><br>
</ww:iterator>

At first I was confused because I kept trying to access the property with the value "errorMap" but luckily a good search found this http://frost.infara.net/archives/2002/11/29/ blog entry where I realized that errorMap was accessed as "errors"

Posted by Andre Mermegas at Feb 03, 2003 14:16 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators