in tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneListRenderer.java [221:263]
private void encodeSelectItem(
FacesContext facesContext, TobagoResponseWriter writer, T component, SelectItem item,
Object value, Object submittedValue, boolean disabled, boolean group) throws IOException {
Object itemValue = item.getValue();
// when using selectItem tag with a literal value: use the converted value
if (itemValue instanceof String && value != null && !(value instanceof String)) {
itemValue = ComponentUtils.getConvertedValue(facesContext, component, (String) itemValue);
}
final String formattedValue = getFormattedValue(facesContext, (T) component, itemValue);
final boolean contains;
if (submittedValue != null) {
contains = submittedValue.equals(formattedValue);
} else {
contains = value != null && value.equals(itemValue);
}
if (item.isNoSelectionOption() && component.isRequired() && value != null && !contains) {
// skip the noSelectionOption if there is another value selected and required
return;
}
writer.startElement(HtmlElements.TR);
writer.writeAttribute(DataAttributes.VALUE, formattedValue, true);
writer.writeClassAttribute(
TobagoClass.SELECT__ITEM,
contains ? BootstrapClass.TABLE_PRIMARY : null,
disabled || item.isDisabled() ? TobagoClass.DISABLED : null,
disabled || item.isDisabled() ? BootstrapClass.DISABLED : null);
writer.writeAttribute(HtmlAttributes.TABINDEX, -1);
writer.startElement(HtmlElements.TD);
writer.writeAttribute(HtmlAttributes.VALUE, formattedValue, true);
if (group) {
writer.startElement(HtmlElements.SPAN);
}
final String label = item.getLabel();
if (label != null) {
writer.writeText(label);
}
if (group) {
writer.endElement(HtmlElements.SPAN);
}
writer.endElement(HtmlElements.TD);
writer.endElement(HtmlElements.TR);
}