for(Iterator<UIComponent> iterator = submenu.getChildren().iterator(); iterator.hasNext();) {
UIComponent child = (UIComponent) iterator.next();
if(child instanceof MenuItem && child.isRendered()) {
MenuItem menuItem = (MenuItem) child;
String menuItemClientId = menuItem.getClientId(facesContext);
String labelStyleClass = menuItem.getStyleClass() == null ? "yuimenuitemlabel" : "yuimenuitemlabel " + menuItem.getStyleClass();
String icon = menuItem.getIcon() != null ? "background:url(" + getResourceURL(facesContext, menuItem.getIcon()) + ") no-repeat 1%;" : null;
writer.startElement("li", null);
writer.writeAttribute("class", "yuimenuitem", null);
if(menuItem.getChildCount() > 0) {
renderChildren(facesContext, menuItem);
} else {
writer.startElement("a", null);
writer.writeAttribute("id", menuItemClientId, null);
writer.writeAttribute("class", labelStyleClass, null);
if(menuItem.getStyle() != null && icon != null)
writer.writeAttribute("style", icon + menuItem.getStyle(), null);
else if(menuItem.getStyle() == null && icon != null)
writer.writeAttribute("style", icon, null);
else if(menuItem.getStyle() != null && icon == null)
writer.writeAttribute("style", menuItem.getStyle() , null);
if(menuItem.getUrl() != null) {
writer.writeAttribute("href", getResourceURL(facesContext, menuItem.getUrl()), null);
if(menuItem.getOnclick() != null) writer.writeAttribute("onclick", menuItem.getOnclick(), null);
if(menuItem.getTarget() != null) writer.writeAttribute("target", menuItem.getTarget(), null);
} else {
writer.writeAttribute("href", "javascript:void(0)", null);
UIComponent form = ComponentUtils.findParentForm(facesContext, submenu);
if(form == null) {
throw new FacesException("Menu must be inside a form element");
}
String formClientId = form.getClientId(facesContext);
String command = menuItem.isAjax() ? buildAjaxRequest(facesContext, menuItem, formClientId, menuItemClientId) : buildNonAjaxRequest(facesContext, menuItem, formClientId, menuItemClientId);
command = menuItem.getOnclick() == null ? command : menuItem.getOnclick() + ";" + command;
writer.writeAttribute("onclick", command, null);
}
//Label is deprecated
if(menuItem.getLabel() != null) writer.write(menuItem.getLabel());
if(menuItem.getValue() != null) writer.write((String) menuItem.getValue());
writer.endElement("a");
}
writer.endElement("li");