jakarta.faces.model.SelectItemGroup Maven / Gradle / Ivy
Show all versions of jakarta.faces Show documentation
/*
* 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.model;
import java.util.Collection;
import jakarta.faces.component.UISelectMany;
import jakarta.faces.component.UISelectOne;
/**
*
* SelectItemGroup is a subclass of {@link SelectItem} that identifies a set of options that will be
* made available as a subordinate "submenu" or "options list", depending upon the requirements of the
* {@link UISelectMany} or {@link UISelectOne} renderer that is actually used. In general, the value
* property of this instance will be ignored, and the label
property of this instance will be used to label
* the submenu.
*
*
*
* Although it is feasible to incorporate {@link SelectItemGroup} instances in he selectItems
property of
* this instance (thereby creating a data structure suitable for cascading submenus), some renderers may place
* restrictions on the level of nesting they support. For example, HTML based renderers that create an
* <select>
element will typically render this instance as an <optgroup>
element,
* but the HTML 4.01 Specification disallows nested option groups.
*
*/
public class SelectItemGroup extends SelectItem {
// ------------------------------------------------------------ Constructors
private static final long serialVersionUID = 8355957402275580167L;
/**
*
* Construct a SelectItemGroup
with no initialized property values.
*
*/
public SelectItemGroup() {
super();
}
/**
*
* Construct a SelectItemGroup
with the specified label and no associated selectItem
s. The
* value
property will be set to a zero-length String, the description
property will be set to
* null
, and the disabled
property will be set to false.
*
*
* @param label Label to be rendered for this group in the response
*
* @throws NullPointerException if label
is false
*/
public SelectItemGroup(String label) {
super("", label);
}
/**
*
* Construct a SelectItemGroup
with the specified properties. The value
property will be set
* to a zero-length String.
*
*
* @param label Label to be rendered for this group in the response
* @param description Description of this group, for use in tools
* @param disabled Flag indicating that this group is disabled
* @param selectItems Variable array of {@link SelectItem} describing the items available in this group
*
* @throws NullPointerException if label
or selectItems
is false
*/
public SelectItemGroup(String label, String description, boolean disabled, SelectItem... selectItems) {
super("", label, description, disabled);
setSelectItems(selectItems);
}
/**
*
* Construct a SelectItemGroup
with the specified properties. The value
property will be set
* to a zero-length String.
*
*
* @param label Label to be rendered for this group in the response
* @param description Description of this group, for use in tools
* @param disabled Flag indicating that this group is disabled
* @param selectItems Collection of {@link SelectItem} describing the items available in this group
*
* @throws NullPointerException if label
or selectItems
is false
*
* @since 4.0
*/
public SelectItemGroup(String label, String description, boolean disabled, Collection extends SelectItem> selectItems) {
super("", label, description, disabled);
setSelectItems(selectItems);
}
// ------------------------------------------------------ Instance Variables
private SelectItem[] selectItems = null;
// -------------------------------------------------------------- Properties
/**
*
* Return the set of subordinate {@link SelectItem}s for this group.
*
*
* @return the set of subordinate {@link SelectItem}s for this group
*/
public SelectItem[] getSelectItems() {
return selectItems;
}
/**
*
* Set the set of subordinate {@link SelectItem}s for this group as a variable array.
*
*
* @param selectItems The new set of subordinate items as a variable array
*
* @throws NullPointerException if selectItems
is null
*/
public void setSelectItems(SelectItem... selectItems) {
if (selectItems == null) {
throw new NullPointerException();
}
this.selectItems = selectItems;
}
/**
*
* Set the set of subordinate {@link SelectItem}s for this group as a collection.
*
*
* @param selectItems The new set of subordinate items as a collection.
*
* @throws NullPointerException if selectItems
is null
*
* @since 4.0
*/
public void setSelectItems(Collection extends SelectItem> selectItems) {
if (selectItems == null) {
throw new NullPointerException();
}
setSelectItems(selectItems.toArray(new SelectItem[selectItems.size()]));
}
}