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

jakarta.faces.component.UISelectBoolean Maven / Gradle / Ivy

/*
 * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package jakarta.faces.component;

import jakarta.el.ValueExpression;

/**
 * 

* UISelectBoolean is a {@link UIComponent} that represents a single boolean (true or * false) value. It is most commonly rendered as a checkbox. *

* *

* By default, the rendererType property must be set to "jakarta.faces.Checkbox". This value * can be changed by calling the setRendererType() method. *

*/ public class UISelectBoolean extends UIInput { // ------------------------------------------------------ Manifest Constants /** *

* The standard component type for this component. *

*/ public static final String COMPONENT_TYPE = "jakarta.faces.SelectBoolean"; /** *

* The standard component family for this component. *

*/ public static final String COMPONENT_FAMILY = "jakarta.faces.SelectBoolean"; // ------------------------------------------------------------ Constructors /** *

* Create a new {@link UISelectBoolean} instance with default property values. *

*/ public UISelectBoolean() { super(); setRendererType("jakarta.faces.Checkbox"); } // -------------------------------------------------------------- Properties @Override public String getFamily() { return COMPONENT_FAMILY; } /** *

* Return the local value of the selected state of this component. This method is a typesafe alias for * getValue(). *

* * @return true if selected, false otherwise. */ public boolean isSelected() { Boolean value = (Boolean) getValue(); if (value != null) { return value.booleanValue(); } return false; } /** *

* Set the local value of the selected state of this component. This method is a typesafe alias for * setValue(). *

* * @param selected The new selected state */ public void setSelected(boolean selected) { setValue(selected); } // ---------------------------------------------------------------- Bindings /** *

* Return any {@link ValueExpression} set for value if a {@link ValueExpression} for selected * is requested; otherwise, perform the default superclass processing for this method. *

* * @param name Name of the attribute or property for which to retrieve a {@link ValueExpression} * * @throws NullPointerException if name is null * @since 1.2 */ @Override public ValueExpression getValueExpression(String name) { if ("selected".equals(name)) { return super.getValueExpression("value"); } return super.getValueExpression(name); } /** *

* Store any {@link ValueExpression} specified for selected under value instead; otherwise, * perform the default superclass processing for this method. *

* * @param name Name of the attribute or property for which to set a {@link ValueExpression} * @param binding The {@link ValueExpression} to set, or null to remove any currently set * {@link ValueExpression} * * @throws NullPointerException if name is null * @since 1.2 */ @Override public void setValueExpression(String name, ValueExpression binding) { if ("selected".equals(name)) { super.setValueExpression("value", binding); } else { super.setValueExpression(name, binding); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy