title: Freemarker - Adding values to hash
body: <p>I'm trying to add values to HashMap in my Freemarker template. I'm also using BeanWrapper so that I can see exposed methods from my Java objects.</p>
  
  <p>In my data model, I have a HashMap:</p>
  
  <pre><code>root.put("myName", new HashMap());
  </code></pre>
  
  <p>As I mentioned above, Im using BeanWrapper so that I can use all the methods of my Java objects:</p>
  
  <pre><code>BeansWrapper wrapper = new BeansWrapper();
  wrapper.setExposureLevel(0);
  cfg.setObjectWrapper(wrapper);//cfg = new Configuration();
  </code></pre>
  
  <p>Now in my template file (test.ftl) I'm trying to invoke put method of HashMap (that I've stored in data model..above):</p>
  
  <pre><code>${myName.put["fname:John"]}
  </code></pre>
  
  <p>This last line does not work, and I'm getting an error:</p>
  
  <pre><code>freemarker.template.TemplateException: Expected hash. myName.put evaluated instead to freemarker.ext.beans.SimpleMethodModel on line 16, column 11 in test.ftl.
  </code></pre>
  
  <p>Could you tell me, how I can invoke <code>put</code> method of my HashMap in template file?</p>