// checkbox menu
UISelectBooleanCheckbox checkbox = (UISelectBooleanCheckbox) menu.getFacet(Facets.CHECKBOX);
boolean checked = ComponentUtils.getBooleanAttribute(checkbox, Attributes.VALUE);
String image = checked ? "image/MenuCheckmark.gif" : null;
String hiddenId = checkbox.getClientId(facesContext);
final CommandMap map = new CommandMap(new Command());
encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, "selectBoolean");
encodeHidden(writer, hiddenId, checked);
} else if (menu.getFacet(Facets.RADIO) != null) {
// radio menu
String clientId = menu.getClientId(facesContext);
UISelectOne radio = (UISelectOne) menu.getFacet(Facets.RADIO);
List<SelectItem> items = RenderUtils.getSelectItems(radio);
String hiddenId = radio.getClientId(facesContext);
for (SelectItem item : items) {
boolean checked = item.getValue().equals(radio.getValue());
String image = checked ? "image/MenuRadioChecked.gif" : null;
final String labelText = item.getLabel();
label.reset();
if (labelText != null) {
if (labelText.indexOf(LabelWithAccessKey.INDICATOR) > -1) {
label.setup(labelText);
} else {
label.setText(labelText);
}
} else {
LOG.warn("Menu item has label=null where clientId=" + clientId);
}
final String formattedValue = RenderUtils.getFormattedValue(facesContext, radio, item.getValue());
final CommandMap map = new CommandMap(
new Command(clientId, null, null, null, null, null, null, null, null, null));
encodeItem(facesContext, writer, null, label, map, disabled, firstLevel, image, formattedValue, "selectOne");
}
encodeHidden(writer, hiddenId, getCurrentValue(facesContext, radio));
} else {
// normal menu command
String image = menu.getImage();
CommandMap map = new CommandMap(new Command(facesContext, menu));
encodeItem(facesContext, writer, menu, label, map, disabled, firstLevel, image, null, null);
}
}