protected void configureMaxLengthAttribute()

in core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/AbstractHtmlCoreComponentsComponentInitializer.java [162:230]


    protected void configureMaxLengthAttribute(FacesContext facesContext,
                                               UIComponent uiComponent,
                                               Map<String, Object> metaData)
    {
        if(metaData.containsKey(CommonMetaDataKeys.MAX_LENGTH))
        {
            Object maxLength = metaData.get(CommonMetaDataKeys.MAX_LENGTH);

            if(!(maxLength instanceof Integer))
            {
                return;
            }

            init(); //lazy init

            if(uiComponent instanceof HtmlInputText)
            {
                HtmlInputText htmlInputText = (HtmlInputText)uiComponent;

                if (this.forceComponentInitialization)
                {
                    htmlInputText.setMaxlength((Integer) maxLength);
                }
                else
                {
                    Integer initialMaxLength = (Integer)
                        htmlInputText.getAttributes().get(INITIAL_MARKUP_META_DATA_KEY);

                    if (initialMaxLength == null)
                    {
                        initialMaxLength = htmlInputText.getMaxlength(); //value overriden by the component
                        htmlInputText.getAttributes().put(INITIAL_MARKUP_META_DATA_KEY, initialMaxLength);
                    }

                    // only override maxlength if not already set by xhtml definition
                    if (initialMaxLength <= 0)
                    {
                        htmlInputText.setMaxlength((Integer) maxLength);
                    }
                }
            }
            else if(uiComponent instanceof HtmlInputSecret)
            {
                HtmlInputSecret htmlInputSecret = (HtmlInputSecret)uiComponent;

                if (this.forceComponentInitialization)
                {
                    htmlInputSecret.setMaxlength((Integer)maxLength);
                }
                else
                {
                    Integer initialMaxLength = (Integer)
                        htmlInputSecret.getAttributes().get(INITIAL_MARKUP_META_DATA_KEY);

                    if (initialMaxLength == null)
                    {
                        initialMaxLength = htmlInputSecret.getMaxlength(); //value overriden by the component
                        htmlInputSecret.getAttributes().put(INITIAL_MARKUP_META_DATA_KEY, initialMaxLength);
                    }

                    // only override maxlength if not already set by xhtml definition
                    if (initialMaxLength <= 0)
                    {
                        htmlInputSecret.setMaxlength((Integer) maxLength);
                    }
                }
            }
        }
    }