All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.faces.component.html.HtmlComponentUtils Maven / Gradle / Ivy

Go to download

Jakarta Faces defines an MVC framework for building user interfaces for web applications, including UI components, state management, event handing, input validation, page navigation, and support for internationalization and accessibility.

There is a newer version: 4.1.2
Show newest version
package jakarta.faces.component.html;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import jakarta.el.ValueExpression;
import jakarta.faces.component.UIComponent;

class HtmlComponentUtils {

    private static final String ATTRIBUTES_THAT_ARE_SET = "jakarta.faces.component.UIComponentBase.attributesThatAreSet";
    private static final String OPTIMIZED_PACKAGE = "jakarta.faces.component.";

    static void handleAttribute(UIComponent component, String name, Object value) {
        final Map attributes = component.getAttributes();

        @SuppressWarnings("unchecked")
        List setAttributes = (List) attributes.get(ATTRIBUTES_THAT_ARE_SET);

        if (setAttributes == null) {
            String className = component.getClass().getName();
            if (className.startsWith(OPTIMIZED_PACKAGE)) {
                setAttributes = new ArrayList<>(6);
                attributes.put(ATTRIBUTES_THAT_ARE_SET, setAttributes);
            }
        }

        if (setAttributes != null) {
            if (value == null) {
                ValueExpression ve = component.getValueExpression(name);
                if (ve == null) {
                    setAttributes.remove(name);
                }
            } else if (!setAttributes.contains(name)) {
                setAttributes.add(name);
            }
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy