O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating the Breadcrumb menu programmatically

We can create dynamic Breadcrumb menus by creating a MenuModel object programmatically and binding the <p:breadcrumb> component's model attribute to the MenuModel instance as follows:

<p:breadCrumb model="#{menuController.breadcrumbMenuModel}"/>
  1. Create the MenuModel component and add menuitems:
    public MenuController() { breadcrumbMenuModel = new DefaultMenuModel(); MenuItem item1 = new MenuItem(); item1.setValue("PrimeFaces"); item1.setUrl("http://www.primefaces.org/"); breadcrumbMenuModel.addMenuItem(item1); MenuItem item2 = new MenuItem(); item2.setValue("Board index"); item2.setUrl("http://forum.primefaces.org/index.php"); breadcrumbMenuModel.addMenuItem(item2); MenuItem item3 = new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required