code: private Component prepareCategoryFacets(CmsSolrResultList solrResultList, CmsSearchResultWrapper resultWrapper) {
  
          FacetField categoryFacets = solrResultList.getFacetField(CmsListManager.FIELD_CATEGORIES);
          I_CmsSearchControllerFacetField facetController = resultWrapper.getController().getFieldFacets().getFieldFacetController().get(
              CmsListManager.FIELD_CATEGORIES);
          if ((categoryFacets != null) && (categoryFacets.getValueCount() > 0)) {
              VerticalLayout catLayout = new VerticalLayout();
              for (final Count value : categoryFacets.getValues()) {
                  Button cat = new Button(getCategoryLabel(value.getName()) + " (" + value.getCount() + ")");
                  cat.addStyleName(ValoTheme.BUTTON_TINY);
                  cat.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                  Boolean selected = facetController.getState().getIsChecked().get(value.getName());
                  if ((selected != null) && selected.booleanValue()) {
                      cat.addStyleName(SELECTED_STYLE);
                  }
                  cat.addClickListener(new ClickListener() {
  
                      private static final long serialVersionUID = 1L;
  
                      public void buttonClick(ClickEvent event) {
  
                          if (isSelected(event.getComponent())) {
                              resetFacetsAndSearch();
                          } else {
                              selectFieldFacet(CmsListManager.FIELD_CATEGORIES, value.getName());
                          }
                      }
                  });
                  catLayout.addComponent(cat);
              }
              Panel catPanel = new Panel(CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_FACET_CATEGORIES_0));
              catPanel.setContent(catLayout);
              return catPanel;
          } else {
              return null;
          }
      }
docs: Prepares the category facets for the given search result.<p>
  
  @param solrResultList the search result list
  @param resultWrapper the result wrapper
  
  @return the category facets component