title: Struts 2 How to display map checkboxlist
body: <p>I have the following code in action:</p>
  
  <pre><code>private Map&lt;Long,String&gt; map = new HashMap&lt;Long, String&gt;();
  
  public Map&lt;Long, String&gt; getMap() {
      return map;
  }
  
  public void setMap(Map&lt;Long, String&gt; map) {
      this.map= map;
  }
  
  public String list() {
          List&lt;Object&gt; list = new ArrayList&lt;&gt;();
          list= objectDAO.listSomething();                        
              for (int i=0; i&lt;list.size(); i++){
                  Object row = (Object) list.get(i);
                  Long id = row.getId();
                  String name = row.getName();
                  map.put(id, name);
              }
          return SUCCESS;
      }
  </code></pre>
  
  <p>After checking with debugger I can see that map is filled with the correct keys and values.</p>
  
  <p>My jsp where the problem occurrs is here:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;s:checkboxlist list = "map" 
               listKey = "%{id.toString()}" 
             listValue = "%{name}" 
                  name = "name" 
                 value = "name" 
                 label = "Label"/&gt;
  </code></pre>
  
  <p>I have also tried something like this, but with no luck:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;s:iterator value="map"&gt;
       &lt;s:checkbox  label="Label" name="name" value="%{value}"/&gt;
       &lt;s:property value="%{value}"/&gt;
  &lt;/s:iterator&gt;
  </code></pre>
  
  <p>The error when hitting the action is this (edited):</p>
  
  <blockquote>
    <p>Error on line 28, column 13 in template/simple/checkboxlist.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey - Class: freemarker.core.Assignment File: Assignment.java Method: accept Line: 111 - freemarker/core/Assignment.java:111:-1</p>
  </blockquote>
  
  <p>Any ideas how to fix this? I have converted code to generic code. Thanks!</p>