-
Book Overview & Buying
-
Table Of Contents
PrimeFaces Cookbook
By :
Programmatic menus offer a more flexible way in comparison to the declarative approach. The whole menu structure can be created in Java and bound as a model to the p:menu tag. Programmatic menu creation is the best choice when we load a menu definition from a database or XML file and the menu structure is not known beforehand.
In this recipe, we will learn about the PrimeFaces menu model and create a programmatic menu.
Every programmatically created menu instance should implement the Java interface org.primefaces.model.MenuModel. PrimeFaces provides a default implementation org.primefaces.model.DefaultMenuModel that is sufficient to use in most cases. Your own customized implementations of MenuModel are possible as well. Let's create a static menu from the Static and dynamic positioned menus recipe in a programmatic way.
@ManagedBean
@ViewScoped
public class ProgrammaticMenuController implements Serializable {
private MenuModel model;
@PostConstruct...
Change the font size
Change margin width
Change background colour