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

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

There is a newer version: 3.1.0.SP02
Show newest version
/*
 * Copyright (c) 1997, 2018 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 javax.faces.component;

import javax.el.ValueExpression;
import javax.faces.el.ValueBinding;

/**
 * 

* 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 * "javax.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 = "javax.faces.SelectBoolean"; /** *

* The standard component family for this component. *

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

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

*/ public UISelectBoolean() { super(); setRendererType("javax.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); } } // ------------------------------------------------------------ Deprecated methods /** *

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

* *

* Rely on the superclass implementation to wrap the returned ValueExpression in a * ValueBinding. *

* * @param name Name of the attribute or property for which to retrieve a {@link ValueBinding} * * @throws NullPointerException if name is null * * @deprecated This has been replaced by {@link #getValueExpression}. */ @Override public ValueBinding getValueBinding(String name) { if ("selected".equals(name)) { return super.getValueBinding("value"); } return super.getValueBinding(name); } /** *

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

* *

* Rely on the superclass implementation to wrap the argument ValueBinding in a * ValueExpression. *

* * @param name Name of the attribute or property for which to set a {@link ValueBinding} * @param binding The {@link ValueBinding} to set, or null to remove any currently * set {@link ValueBinding} * * @throws NullPointerException if name is null * * @deprecated This has been replaced by {@link #setValueExpression}. */ @Override public void setValueBinding(String name, ValueBinding binding) { if ("selected".equals(name)) { super.setValueBinding("value", binding); } else { super.setValueBinding(name, binding); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy