protected void encodeBeginSurroundingLabel()

in tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/LabelLayoutRendererBase.java [115:198]


  protected void encodeBeginSurroundingLabel(final FacesContext facesContext, final T component)
      throws IOException {

    final TobagoResponseWriter writer = getResponseWriter(facesContext);
    final String clientId =
        component instanceof RenderRange && ((RenderRange) component).getRenderRangeReference() != null
            ? ((RenderRange) component).getRenderRangeReference().getClientId(facesContext)
            : component.getClientId(facesContext);
    final Markup markup = (Markup) ComponentUtils.getAttribute(component, Attributes.markup);

    final boolean autoSpacing = component.getAutoSpacing(facesContext);
    final LabelLayout labelLayout = component.getLabelLayout();
    final boolean nextToRenderIsLabel = component.isNextToRenderIsLabel();
    final boolean flex;
    final boolean flow;

    switch (labelLayout) {
      case flexLeft:
      case flexRight:
        flex = true;
        break;
      case segmentLeft:
      case segmentRight:
        flex = false;
        break;
      case flowLeft:
      case gridLeft:
      case gridRight:
      case gridTop:
      case gridBottom:
        encodeLabel(facesContext, component, writer, labelLayout);
        flex = false;
        break;
      case none:
      case top:
      case flowRight:
      default:
        flex = false;
    }

    switch (labelLayout) {
      case flowLeft:
      case flowRight:
        flow = true;
        break;
      default:
        flow = false;
    }

    if (nextToRenderIsLabel) {
      // skip, because its only the lable to render
    } else {
      writer.startElement(getComponentTag());
      writer.writeIdAttribute(clientId);
      writer.writeClassAttribute(
          flex ? TobagoClass.LABEL__CONTAINER : null,
          getComponentCss(facesContext, component),
          autoSpacing ? TobagoClass.AUTO__SPACING : null,
          ComponentUtils.getBooleanAttribute(component, Attributes.required) ? TobagoClass.REQUIRED : null,
          flow ? TobagoClass.DISPLAY__INLINE__BLOCK : null,
          markup != null && markup.contains(Markup.SPREAD) ? TobagoClass.SPREAD : null);
      writeAdditionalAttributes(facesContext, writer, component);
    }

    switch (labelLayout) {
      case none:
      case flexRight:
      case flowRight:
      case flowLeft:
      case gridLeft:
      case gridRight:
      case gridTop:
      case gridBottom:
        break;
      case segmentLeft:
      case segmentRight:
        if (nextToRenderIsLabel) {
          encodeLabel(facesContext, component, writer, labelLayout);
        }
        break;
      default:
        encodeLabel(facesContext, component, writer, labelLayout);
    }
  }