protected void encodeMenuItemContent(FacesContext context, AbstractMenu menu, MenuItem menuitem)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String icon = menuitem.getIcon();
    Object value = menuitem.getValue();

    if (icon != null) {
      writer.startElement("span", null);
      writer.writeAttribute("class", AbstractMenu.MENUITEM_ICON_CLASS + " " + icon, null);
      writer.endElement("span");
    }

    writer.startElement("span", null);
    writer.writeAttribute("class", AbstractMenu.MENUITEM_TEXT_CLASS, null);

    if (value != null) {
      if (menuitem.isEscape()) writer.writeText(value, "value");
      else writer.write(value.toString());
    } else if (menuitem.shouldRenderChildren()) {
      renderChildren(context, (UIComponent) menuitem);
    }

    writer.endElement("span");
  }