title: Primefaces : how to create <p:menubar> dynamically in primefaces 4?
body: <p>i'm migrating from primefaces 3.4 to primfaces 4.I had the menubar created dinamically in primefaces 3.4 with no probleme.
  here is the bean:</p>
  
  <pre><code>public MenuBean() {
      MenuItem menuItem = new MenuItem();
      Submenu submenu = new Submenu();
  
  
      submenu.setLabel("Nos Solutions");
      menuItem.setValue("Computers");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      menuItem = new MenuItem();
      menuItem.setValue("Clothes");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      simpleMenuModel.addSubmenu(submenu);
  
      submenu = new Submenu();
      submenu.setLabel("Nos Problemes");
      menuItem.setValue("Computers");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      menuItem = new MenuItem();
      menuItem.setValue("Clothes");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      simpleMenuModel.addSubmenu(submenu);
  
      submenu = new Submenu();
      submenu.setLabel("Nos Solutions");
      menuItem.setValue("Computers");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      menuItem = new MenuItem();
      menuItem.setValue("Clothes");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      simpleMenuModel.addSubmenu(submenu);
  
      submenu = new Submenu();
      submenu.setLabel("Nos Solutions");
      menuItem.setValue("Computers");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      Submenu submenu1 = new Submenu();
      submenu1.setLabel("Offres");
      menuItem = new MenuItem();
      menuItem.setValue("Stage Etudiants");
      menuItem.setUrl("#");
      submenu1.getChildren().add(menuItem);
      menuItem = new MenuItem();
      menuItem.setValue("Jeunes diplomés");
      menuItem.setUrl("#");
      submenu1.getChildren().add(menuItem);
  
      submenu.getChildren().add(submenu1);
      menuItem = new MenuItem();
      menuItem.setValue("Clothes");
      menuItem.setUrl("#");
      submenu.getChildren().add(menuItem);
  
      simpleMenuModel.addSubmenu(submenu);
      menuItem = new MenuItem();
      menuItem.setValue("Clothe");
      menuItem.setUrl("#");
      simpleMenuModel.addMenuItem(menuItem);
  
  }
  
  public MenuModel getSimpleMenuModel() {
      return simpleMenuModel;
  }
  </code></pre>
  
  <p>here the xhtml:
  <code>&lt;p:menubar model="#{menuBean.simpleMenuModel}"/&gt;</code></p>
  
  <p>now in primefaces 4 the classes/interfaces seems to be changed, and i don't know to do it in this version.
  can anyone help please !!!.</p>