Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package javax.faces.model;
 
 

SelectItem represents a single item in the list of supported items associated with a javax.faces.component.UISelectMany or javax.faces.component.UISelectOne component.

 
 
 public class SelectItem implements Serializable {
 
     private static final long serialVersionUID = 876782311414654999L;
 
 
     // ------------------------------------------------------------ Constructors
 

    

Construct a SelectItem with no initialized property values.

 
     public SelectItem() {
 
         super();
 
     }


    

Construct a SelectItem with the specified value. The label property will be set to the value (converted to a String, if necessary), the description property will be set to null, the disabled property will be set to false, and the escape property will be set to ( true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
 
     public SelectItem(Object value) {
 
         this(valuevalue == null ? null : value.toString(), nullfalsetruefalse);
 
     }


    

Construct a SelectItem with the specified value and label. The description property will be set to null, the disabled property will be set to false, and the escape property will be set to true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
    public SelectItem(Object valueString label) {
        this(valuelabelnullfalsetruefalse);
    }


    

Construct a SelectItem instance with the specified value, label and description. This disabled property will be set to false, and the escape property will be set to true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
    public SelectItem(Object valueString labelString description) {
        this(valuelabeldescriptionfalsetruefalse);
    }


    

Construct a SelectItem instance with the specified property values. The escape property will be set to true.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
disabled Flag indicating that this option is disabled
    public SelectItem(Object valueString labelString description,
                      boolean disabled) {
        this(valuelabeldescriptiondisabledtruefalse);
    }
    
    

Construct a SelectItem instance with the specified property values.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
disabled Flag indicating that this option is disabled
escape Flag indicating that the text of this option should be escaped when rendered.
Since:
1.2
    public SelectItem(Object valueString labelString description,
                      boolean disabledboolean escape) {
        this(valuelabeldescriptiondisabledescapefalse);
    }
    
    
    

Construct a SelectItem instance with the specified property values.

Parameters:
value Value to be delivered to the model if this item is selected by the user
label Label to be rendered for this item in the response
description Description of this item, for use in tools
disabled Flag indicating that this option is disabled
escape Flag indicating that the text of this option should be escaped when rendered.
noSelectionOption Flag indicating that the current option is a "no selection" option
Since:
1.2
    public SelectItem(Object valueString labelString description,
                      boolean disabledboolean escapeboolean noSelectionOption) {
        super();
        setValue(value);
        setLabel(label);
        setDescription(description);
        setDisabled(disabled);
        setEscape(escape);
        setNoSelectionOption(noSelectionOption);
    }
    
    // ------------------------------------------------------ Instance Variables
    private String description = null;
    private boolean disabled = false;
    private String label = null;
    @SuppressWarnings({"NonSerializableFieldInSerializableClass"})
    private Object value = null;
    // -------------------------------------------------------------- Properties


    

Return a description of this item, for use in development tools.

    public String getDescription() {
        return (this.);
    }


    

Set the description of this item, for use in development tools.

Parameters:
description The new description
    public void setDescription(String description) {
        this. = description;
    }


    

Return the disabled flag for this item, which should modify the rendered output to make this item unavailable for selection by the user if set to true.

    public boolean isDisabled() {
        return (this.);
    }


    

Set the disabled flag for this item, which should modify the rendered output to make this item unavailable for selection by the user if set to true.

Parameters:
disabled The new disabled flag
    public void setDisabled(boolean disabled) {
        this. = disabled;
    }


    

Return the label of this item, to be rendered visibly for the user.

    public String getLabel() {
        return (this.);
    }


    

Set the label of this item, to be rendered visibly for the user.

Parameters:
label The new label
    public void setLabel(String label) {
        this. = label;
    }


    

Return the value of this item, to be delivered to the model if this item is selected by the user.

    public Object getValue() {
        return (this.);
    }


    

Set the value of this item, to be delivered to the model if this item is selected by this user.

Parameters:
value The new value
    public void setValue(Object value) {
        this. = value;
    }
    private boolean escape;

    

If and only if this returns true, the code that renders this select item must escape the label using escaping syntax appropriate to the content type being rendered.

Since:
2.0
    public boolean isEscape() {
        return this.;
    }

    

Set the value of the escape property. See isEscape().

Since:
2.0
    public void setEscape(boolean escape) {
        this. = escape;
    }
    
    private boolean noSelectionOption = false;

    

Return the value of the noSelectionOption property. If the value of this property is true, the system interprets the option represented by this SelectItem instance as representing a "no selection" option. See javax.faces.component.UISelectOne.validateValue(javax.faces.context.FacesContext,java.lang.Object) and javax.faces.component.UISelectMany.validateValue(javax.faces.context.FacesContext,java.lang.Object) for usage.

Since:
2.0
    public boolean isNoSelectionOption() {
        return ;
    }

    

Set the value of the noSelectionOption property.

Since:
2.0
    public void setNoSelectionOption(boolean noSelectionOption) {
        this. = noSelectionOption;
    }
New to GrepCode? Check out our FAQ X