title: Using Primefaces 5, should I be able to *dynamically* build a simple p:menu containing only menuitems? ...i.e., without submenu(s)?
body: <p><strong>QUESTION:</strong> Using Primefaces 5, can I dynamically build a simple p:menu containing only menuitems - i.e., without submenu(s)?</p>
  
  <p>For example,  I am able to successfully implement this static menu...</p>
  
  <pre><code>    -
      -
      -
      &lt;h3&gt;Static p:menu  (i.e., no submenus) - WORKING &lt;/h3&gt;
      &lt;p:menu id="menustatic"&gt;
          &lt;p:menuitem value="operation1"  action="#{breadCrumb.navigate('page0')}" /&gt;
          &lt;p:menuitem value="operation2"  action="#{breadCrumb.navigate('page1')}" /&gt;
          &lt;p:menuitem value="operation3"  action="#{breadCrumb.navigate('page2')}" /&gt;
      &lt;/p:menu&gt;
      -
      -
      -
  </code></pre>
  
  <p>But, when I attempt to implement the above menu dyamically from the managed bean, it is not working... i.e., </p>
  
  <p>the controller method</p>
  
  <pre><code>    -
      -
      -
      private DynamicMenuModel menuModel;
      public MenuModel getMenuModel()
      {
          menuModel = new DynamicMenuModel();
  
          DefaultMenuItem item = new DefaultMenuItem();
          item.setIcon("ui-icon ui-icon-newwin");
          item.setValue("operation1a");
          item.setCommand("#{breadCrumb.navigate('page0')}");
          menuModel.addElement(item);
  
          item = new DefaultMenuItem();
          item.setIcon("ui-icon ui-icon-newwin");
          item.setValue("operation1b");
          item.setCommand("#{breadCrumb.navigate('page1')}");
          menuModel.addElement(item);
  
          item = new DefaultMenuItem();
          item.setIcon("ui-icon ui-icon-newwin");
          item.setValue("operation1c");
          item.setCommand("#{breadCrumb.navigate('page2')}");
          menuModel.addElement(item);
  
          return menuModel;
      }
      -
      -
      -
  </code></pre>
  
  <p>the page/tag</p>
  
  <pre><code>    &lt;h3&gt;Dyamic p:menu  (i.e., no submenus) -  NOT WORKING &lt;/h3&gt;
      &lt;p:menu id="menudynamic" model="#{menuController.menuModel}" /&gt;   
  </code></pre>
  
  <p>When I click on the "dynamically" built menu's menuitems I receive this error on my console...</p>
  
  <pre><code>    &lt;Jul 17, 2014 1:12:52 PM EDT&gt; &lt;Warning&gt; &lt;javax.enterprise.resource.webcontainer.jsf.lifecycle&gt; &lt;BEA-000000&gt; &lt;For input string: "null"
      java.lang.NumberFormatException: For input string: "null"
          at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
          at java.lang.Integer.parseInt(Integer.java:449)
          at java.lang.Integer.parseInt(Integer.java:499)
          at org.primefaces.component.menu.BaseMenuRenderer.findMenuitem(BaseMenuRenderer.java:83)
          at org.primefaces.component.menu.BaseMenuRenderer.decode(BaseMenuRenderer.java:61)
          Truncated. see log file for complete stacktrace
      &gt;       
  </code></pre>
  
  <p><em>Is the problem that I am simply misusing the "p:menu" tag in the first place, when I build the static version?... 
  - Is this why my attempting to build a dynamic version of the same menu does not work as I would expect?</em></p>
  
  <p>Thanks for any help!</p>
  
  <p>:)</p>