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

de.larmic.jsf2.component.html.HtmlComboBox Maven / Gradle / Ivy

The newest version!
package de.larmic.jsf2.component.html;

import javax.el.ValueExpression;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.FacesComponent;
import javax.faces.component.html.HtmlSelectOneMenu;

@ResourceDependencies({ @ResourceDependency(library = "css", name = "larmic-jsf2-components.css", target = "head"),
		@ResourceDependency(library = "js", name = "larmic-jsf2-components.js", target = "head") })
@FacesComponent(HtmlComboBox.COMPONENT_TYPE)
public class HtmlComboBox extends HtmlSelectOneMenu implements HtmlInputComponent {

	public static final String COMPONENT_TYPE = "de.larmic.component.comboBox";
	public static final String COMPONENT_FAMILY = "de.larmic.component.family";
	public static final String RENDERER_TYPE = "de.larmic.jsf2.renderkit.html_basic.ComboBoxRenderer";

	protected static final String PROPERTY_FLOATING = "floating";
    protected static final String PROPERTY_DISABLE_STYLE_CLASSES = "disableDefaultStyleClasses";
	protected static final String PROPERTY_TOOLTIP = "tooltip";
    protected static final String PROPERTY_COMPONENT_STYLE_CLASS = "componentStyleClass";
    protected static final String PROPERTY_INPUT_STYLE_CLASS = "inputStyleClass";
    protected static final String PROPERTY_LABEL_STYLE_CLASS = "labelStyleClass";

	public HtmlComboBox() {
		super();
		this.setRendererType(RENDERER_TYPE);
	}

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}

    @Override
    public String getComponentStyleClass() {
        return (String) this.getStateHelper().eval(PROPERTY_COMPONENT_STYLE_CLASS);
    }

    public void setComponentStyleClass(final String componentStyleClass) {
        this.updateStateHelper(PROPERTY_COMPONENT_STYLE_CLASS, componentStyleClass);
    }

    @Override
    public String getInputStyleClass() {
        return (String) this.getStateHelper().eval(PROPERTY_INPUT_STYLE_CLASS);
    }

    public void setInputStyleClass(final String inputStyleClass) {
        this.updateStateHelper(PROPERTY_INPUT_STYLE_CLASS, inputStyleClass);
    }

    @Override
    public String getLabelStyleClass() {
        return (String) this.getStateHelper().eval(PROPERTY_LABEL_STYLE_CLASS);
    }

    public void setLabelStyleClass(final String labelStyleClass) {
        this.updateStateHelper(PROPERTY_LABEL_STYLE_CLASS, labelStyleClass);
    }

	@Override
	public String getTooltip() {
		return (String) this.getStateHelper().eval(PROPERTY_TOOLTIP);
	}

	public void setTooltip(final String tooltip) {
		this.updateStateHelper(PROPERTY_TOOLTIP, tooltip);
	}

    @Override
    public boolean getDisableDefaultStyleClasses() {
        return (Boolean) this.getStateHelper().eval(PROPERTY_DISABLE_STYLE_CLASSES, false);
    }

    public void setDisableDefaultStyleClasses(final Boolean disableDefaultStyleClasses) {
        this.updateStateHelper(PROPERTY_DISABLE_STYLE_CLASSES, disableDefaultStyleClasses);
    }

	@Override
	public boolean getFloating() {
		return (Boolean) this.getStateHelper().eval(PROPERTY_FLOATING, false);
	}

	public void setFloating(final Boolean floating) {
		this.updateStateHelper(PROPERTY_FLOATING, floating);
	}

	private void updateStateHelper(final String propertyName, final Object value) {
		this.getStateHelper().put(propertyName, value);

		final ValueExpression ve = this.getValueExpression(propertyName);

		if (ve != null) {
			ve.setValue(this.getFacesContext().getELContext(), value);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy