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 – grouping options in SelectOneMenu

Let us see how to display SelectOneMenu options in groups, by performing the following step:

  1. Create the SelectOneMenu component with option groups using the SelectItemGroup and SelectItem objects:
    @ManagedBean @RequestScoped public class SelectionController { private List<SelectItem> tagItems = new ArrayList<SelectItem>(); private String selectedTagItem; public SelectionController() { SelectItemGroup g1 = new SelectItemGroup("JavaSE"); g1.setSelectItems(new SelectItem[] {new SelectItem("Threads", "Threads"), new SelectItem("JDBC", "JDBC")}); SelectItemGroup g2 = new SelectItemGroup("JavaEE"); g2.setSelectItems(new SelectItem[] {new SelectItem("JPA", "JPA"), new SelectItem("JMS", "JMS"), new SelectItem("EJB", ...

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