<commit_before>package de.larmic.butterfaces.component.partrenderer;

import de.larmic.butterfaces.component.base.renderer.HtmlBasicRenderer;
import de.larmic.butterfaces.component.html.HtmlInputComponent;
import de.larmic.butterfaces.component.html.HtmlTextArea;
import de.larmic.butterfaces.component.html.feature.MaxLength;

import javax.faces.component.UIInput;
import javax.faces.context.ResponseWriter;
import java.io.IOException;

public class MaxLengthPartRenderer {

    public void renderMaxLength(final HtmlInputComponent component, final ResponseWriter writer) throws IOException {
        final UIInput uiComponent = (UIInput) component;
        final String outerComponentId = component.getClientId();

        if (isMaxLengthNecessary(component)) {
            renderMaxLengthElement(writer, uiComponent);
            RenderUtils.renderJQueryPluginCall(outerComponentId, "butterMaxLength({maxLength:"
                    + ((HtmlTextArea) component).getMaxLength() + "})", writer, uiComponent);
        }
    }

    private void renderMaxLengthElement(final ResponseWriter writer, final UIInput uiComponent) throws IOException {
        writer.startElement(HtmlBasicRenderer.ELEMENT_DIV, uiComponent);
        writer.writeAttribute("class", Constants.TEXT_AREA_MAXLENGTH_COUNTER_CLASS, null);
        writer.endElement(HtmlBasicRenderer.ELEMENT_DIV);
    }


    private boolean isMaxLengthNecessary(final HtmlInputComponent component) {
        return ((MaxLength) component).getMaxLength() != null;
    }
}
<commit_msg>BUT-377 Fixed maxLength attribute on markdown component<commit_after>package de.larmic.butterfaces.component.partrenderer;

import de.larmic.butterfaces.component.base.renderer.HtmlBasicRenderer;
import de.larmic.butterfaces.component.html.HtmlInputComponent;
import de.larmic.butterfaces.component.html.feature.MaxLength;

import javax.faces.component.UIInput;
import javax.faces.context.ResponseWriter;
import java.io.IOException;

public class MaxLengthPartRenderer {

    public void renderMaxLength(final HtmlInputComponent component, final ResponseWriter writer) throws IOException {
        final UIInput uiComponent = (UIInput) component;
        final String outerComponentId = component.getClientId();

        if (isMaxLengthNecessary(component)) {
            renderMaxLengthElement(writer, uiComponent);
            RenderUtils.renderJQueryPluginCall(outerComponentId, "butterMaxLength({maxLength:"
                    + ((MaxLength) component).getMaxLength() + "})", writer, uiComponent);
        }
    }

    private void renderMaxLengthElement(final ResponseWriter writer, final UIInput uiComponent) throws IOException {
        writer.startElement(HtmlBasicRenderer.ELEMENT_DIV, uiComponent);
        writer.writeAttribute("class", Constants.TEXT_AREA_MAXLENGTH_COUNTER_CLASS, null);
        writer.endElement(HtmlBasicRenderer.ELEMENT_DIV);
    }


    private boolean isMaxLengthNecessary(final HtmlInputComponent component) {
        return component instanceof MaxLength && ((MaxLength) component).getMaxLength() != null;
    }
}

{'fraction_non_alphanumeric': 0.08649173955296405, 'fraction_numerical': 0.0009718172983479105, 'mean_word_length': 4.604355716878403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3233736', 'n_tokens_mistral': 834, 'n_tokens_neox': 814, 'n_words': 153}