in tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/LabelLayoutRendererBase.java [225:260]
protected void encodeLabel(
final FacesContext facesContext, final T component,
final TobagoResponseWriter writer, final LabelLayout labelLayout)
throws IOException {
// TBD: maybe use an interface for getLabel()
final String label = ComponentUtils.getStringAttribute(component, Attributes.label);
final Markup markup =
component instanceof Visual && ((Visual) component).getMarkup() != null ? ((Visual) component).getMarkup()
: Markup.NULL;
if (StringUtils.isNotBlank(label)) {
writer.startElement(HtmlElements.LABEL);
if (labelLayout == LabelLayout.gridLeft || labelLayout == LabelLayout.gridRight
|| labelLayout == LabelLayout.gridTop || labelLayout == LabelLayout.gridBottom) {
final String clientId =
component instanceof RenderRange && ((RenderRange) component).getRenderRangeReference() != null
? ((RenderRange) component).getRenderRangeReference().getClientId(facesContext)
: component.getClientId(facesContext);
final String labelId = clientId + ComponentUtils.SUB_SEPARATOR + "label";
writer.writeIdAttribute(labelId);
}
writer.writeAttribute(HtmlAttributes.FOR, getFieldId(facesContext, component), false);
writer.writeClassAttribute(
ComponentUtils.getBooleanAttribute(component, Attributes.required) ? TobagoClass.REQUIRED : null,
BootstrapClass.COL_FORM_LABEL,
markup.contains(Markup.LARGE) ? BootstrapClass.COL_FORM_LABEL_LG : null,
markup.contains(Markup.SMALL) ? BootstrapClass.COL_FORM_LABEL_SM : null);
if (component instanceof SupportsAccessKey) {
final LabelWithAccessKey labelWithAccessKey = new LabelWithAccessKey((SupportsAccessKey) component);
HtmlRendererUtils.writeLabelWithAccessKey(writer, labelWithAccessKey);
} else {
writer.writeText(label);
}
writer.endElement(HtmlElements.LABEL);
}
}