code: public static String encodeComponentWithSurroundingDiv(final FacesContext context,
                                                             final UIComponent component,
                                                             final String styleClass) throws IOException {
          if (StringUtils.isNotEmpty(styleClass)) {
              return "<div class=\"" + styleClass + "\">" + encodeComponent(context, component) + "</div>";
          }
          return "<div>" + encodeComponent(context, component) + "</div>";
      }
docs: Encodes complete component by calling {@link UIComponent#encodeAll(FacesContext)}.
  
  @param component  component
  @param context    {@link FacesContext}
  @param styleClass a div wrapper style class
  @return the rendered string.
  @throws IOException thrown by writer