import java.util.List;
public class ColumnMenuRenderer extends PopupMenuRenderer {
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
ColumnMenu menu = (ColumnMenu) component;
if (menu.getChildren().size() == 0) {
List<UIComponent> menuItems = menu.getChildren();
menuItems.add(Components.createComponent(context, SortAscendingMenuItem.COMPONENT_TYPE, SortAscendingMenuItem.class, menu, "sortAscending"));
menuItems.add(Components.createComponent(context, SortDescendingMenuItem.COMPONENT_TYPE, SortDescendingMenuItem.class, menu, "sortDescend"));
if (getTable(menu).getUnsortedStateAllowed()) {
menuItems.add(Components.createComponent(context, ResetSortingMenuItem.COMPONENT_TYPE, ResetSortingMenuItem.class, menu, "resetSorting"));
}