}
@Override
public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
final UIMenu menu = (UIMenu) component;
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
final LabelWithAccessKey label = new LabelWithAccessKey(menu);
final boolean disabled = menu.isDisabled();
final boolean firstLevel = !RendererTypes.MENU.equals(menu.getParent().getRendererType());
final boolean isParentMenu = menu.getChildCount() > 0; // todo: may be not correct
writer.startElement(HtmlElements.LI, menu);
writer.writeClassAttribute(Classes.create(menu));
StringBuilder backgroundImage = null;
StringBuilder backgroundPosition = null;
if (menu.getImage() != null) {
backgroundImage = new StringBuilder();
backgroundPosition = new StringBuilder();
backgroundImage.append("url('");
backgroundImage.append(
ResourceManagerUtils.getImageOrDisabledImageWithPath(facesContext, menu.getImage(), menu.isDisabled()));
backgroundImage.append("')");
backgroundPosition.append("left center");
}
if (isParentMenu && !firstLevel) {
if (backgroundImage == null) {
backgroundImage = new StringBuilder();
backgroundPosition = new StringBuilder();
} else {
backgroundImage.append(",");
backgroundPosition.append(",");
}
backgroundImage.append("url('");
backgroundImage.append(
ResourceManagerUtils.getImageOrDisabledImageWithPath(facesContext, "image/MenuArrow.gif", menu.isDisabled()));
backgroundImage.append("')");
backgroundPosition.append("right center");
}
if (backgroundImage != null) {
final Style style = new Style();