protected void encodeBeginField()

in tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DateRenderer.java [89:159]


  protected void encodeBeginField(final FacesContext facesContext, final T date) throws IOException {
    final TobagoResponseWriter writer = getResponseWriter(facesContext);

    final UIComponent after = ComponentUtils.getFacet(date, Facets.after);
    final UIComponent before = ComponentUtils.getFacet(date, Facets.before);

    writer.startElement(HtmlElements.DIV);
    writer.writeClassAttribute(BootstrapClass.INPUT_GROUP);

    encodeGroupAddon(facesContext, writer, before, false);

    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, date);
    final DateType type = date.getType();

    final String currentValue = getCurrentValue(facesContext, date);
    final String clientId = date.getClientId(facesContext);
    final String fieldId = date.getFieldId(facesContext);
    final boolean readonly = date.isReadonly();
    final boolean disabled = date.isDisabled();
    final boolean required = ComponentUtils.getBooleanAttribute(date, Attributes.required);
    final Markup markup = date.getMarkup() != null ? date.getMarkup() : Markup.NULL;

    writer.startElement(HtmlElements.INPUT);

    if (date.getAccessKey() != null) {
      writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(date.getAccessKey()), false);
      AccessKeyLogger.addAccessKey(facesContext, date.getAccessKey(), clientId);
    }

    writer.writeAttribute(HtmlAttributes.TYPE, type.getName(), false);
    final Double step = date.getStep();
    if (step != null) {
      writer.writeAttribute(HtmlAttributes.STEP, Double.toString(step), false);
    }
    writer.writeNameAttribute(clientId);
    writer.writeIdAttribute(fieldId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, date);
    writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
    writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    writer.writeAttribute(HtmlAttributes.TABINDEX, date.getTabIndex());
    writer.writeAttribute(HtmlAttributes.MIN, convertToString(date.getMin()), true);
    if (date.getMax() == null && DateType.DATE.equals(type)) {
      writer.writeAttribute(HtmlAttributes.MAX, "9999-12-31", false);
    } else if (date.getMax() == null && DateType.DATETIME_LOCAL.equals(type)) {
      writer.writeAttribute(HtmlAttributes.MAX, "9999-12-31T23:59", false);
    } else {
      writer.writeAttribute(HtmlAttributes.MAX, convertToString(date.getMax()), true);
    }

    writer.writeClassAttribute(
        BootstrapClass.validationColor(ComponentUtils.getMaximumSeverity(date)),
        BootstrapClass.FORM_CONTROL,
        markup.contains(Markup.LARGE) ? BootstrapClass.FORM_CONTROL_LG : null,
        markup.contains(Markup.SMALL) ? BootstrapClass.FORM_CONTROL_SM : null,
        date.getCustomClass());

    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
    renderFocus(clientId, date.isFocus(), date.isError(), facesContext, writer);

    writer.endElement(HtmlElements.INPUT);

    encodeBehavior(writer, facesContext, date);

    encodeGroupAddon(facesContext, writer, after, true);

    if (date.isTodayButton()) {
      encodeButton(facesContext, date, type);
    }
  }