@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
MenuItem menuItem = (MenuItem) component;
ResponseWriter writer = context.getResponseWriter();
PopupMenu popupMenu = (PopupMenu) menuItem.getParent();
writer.startElement("li", menuItem);
writeAttribute(writer, "class", DEFAULT_LIST_ITEM_CLASS);
writeAttribute(writer, "id", menuItem.getClientId(context));
renderStartMenuItemSpan(context, menuItem, writer);
renderStyleClass(context, menuItem, writer);
addSelectedStyleClass(context, menuItem);
renderMenuItemImage(context, menuItem, writer, popupMenu);
//content span
writer.startElement("span", menuItem);
writeAttribute(writer, "id", menuItem.getClientId(context) + SPAN_SUFIX);
String contentClass = Styles.getCSSClass(context, menuItem, menuItem.getContentAreaStyle(), StyleGroup.regularStyleGroup(),
menuItem.getContentAreaClass(), Styles.getCSSClass(context, popupMenu, popupMenu.getItemContentStyle(), StyleGroup.regularStyleGroup(),
popupMenu.getItemContentClass(), DEFAULT_CONTENT_CLASS));
writeAttribute(writer, "class", contentClass);
renderContentStyleClass(context, menuItem, writer);