Home » Mojarra-2.0.1 » javax » faces » component » [javadoc | source]

    1   /*
    2    * $Id: UISelectItem.java,v 1.41 2007/10/18 17:05:24 rlubke Exp $
    3    */
    4   
    5   /*
    6    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    7    * 
    8    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    9    * 
   10    * The contents of this file are subject to the terms of either the GNU
   11    * General Public License Version 2 only ("GPL") or the Common Development
   12    * and Distribution License("CDDL") (collectively, the "License").  You
   13    * may not use this file except in compliance with the License. You can obtain
   14    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   15    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   16    * language governing permissions and limitations under the License.
   17    * 
   18    * When distributing the software, include this License Header Notice in each
   19    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   20    * Sun designates this particular file as subject to the "Classpath" exception
   21    * as provided by Sun in the GPL Version 2 section of the License file that
   22    * accompanied this code.  If applicable, add the following below the License
   23    * Header, with the fields enclosed by brackets [] replaced by your own
   24    * identifying information: "Portions Copyrighted [year]
   25    * [name of copyright owner]"
   26    * 
   27    * Contributor(s):
   28    * 
   29    * If you wish your version of this file to be governed by only the CDDL or
   30    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   31    * elects to include this software in this distribution under the [CDDL or GPL
   32    * Version 2] license."  If you don't indicate a single choice of license, a
   33    * recipient has the option to distribute your version of this file under
   34    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   35    * its licensees as provided above.  However, if you add GPL Version 2 code
   36    * and therefore, elected the GPL Version 2 license, then the option applies
   37    * only if the new code is made subject to such option by the copyright
   38    * holder.
   39    */
   40   
   41   package javax.faces.component;
   42   
   43   
   44   import javax.faces.model.SelectItem;
   45   
   46   
   47   
   48   /**
   49    * <p><strong class="changed_modified_2_0">UISelectItem</strong> is a
   50    * component that may be nested inside a {@link UISelectMany} or {@link
   51    * UISelectOne} component, and causes the addition of a {@link
   52    * SelectItem} instance to the list of available options for the parent
   53    * component.  The contents of the {@link SelectItem} can be specified
   54    * in one of the following ways:</p> <ul> <li>The <code>value</code>
   55    * attribute's value is an instance of {@link SelectItem}.</li> <li>The
   56    * associated {@link javax.el.ValueExpression} points at a model data
   57    * item of type {@link SelectItem}.</li> <li>A new {@link SelectItem}
   58    * instance is synthesized from the values of the
   59    * <code>itemDescription</code>, <code>itemDisabled</code>,
   60    * <code>itemLabel</code>, <code>itemEscaped</code>, and
   61    * <code>itemValue</code> attributes.</li> </ul>
   62    */
   63   
   64   public class UISelectItem extends UIComponentBase {
   65   
   66   
   67       // ------------------------------------------------------ Manifest Constants
   68   
   69   
   70       /**
   71        * <p>The standard component type for this component.</p>
   72        */
   73       public static final String COMPONENT_TYPE = "javax.faces.SelectItem";
   74   
   75   
   76       /**
   77        * <p>The standard component family for this component.</p>
   78        */
   79       public static final String COMPONENT_FAMILY = "javax.faces.SelectItem";
   80   
   81   
   82       enum PropertyKeys {
   83           itemDescription,
   84           itemDisabled,
   85           itemEscaped,
   86           itemLabel,
   87           itemValue,
   88           value,
   89           noSelectionOption
   90       }
   91   
   92   
   93       // ------------------------------------------------------------ Constructors
   94   
   95   
   96       /**
   97        * <p>Create a new {@link UISelectItem} instance with default property
   98        * values.</p>
   99        */
  100       public UISelectItem() {
  101   
  102           super();
  103           setRendererType(null);
  104   
  105       }
  106   
  107   
  108       // -------------------------------------------------------------- Properties
  109   
  110   
  111       public String getFamily() {
  112   
  113           return (COMPONENT_FAMILY);
  114   
  115       }
  116   
  117   
  118       /**
  119        * <p>Return the description for this selection item.</p>
  120        */
  121       public String getItemDescription() {
  122   
  123           return (String) getStateHelper().eval(PropertyKeys.itemDescription);
  124   
  125       }
  126   
  127   
  128       /**
  129        * <p>Set the description for this selection item.</p>
  130        *
  131        * @param itemDescription The new description
  132        */
  133       public void setItemDescription(String itemDescription) {
  134   
  135           getStateHelper().put(PropertyKeys.itemDescription, itemDescription);
  136   
  137       }
  138   
  139       /**
  140        * <p>Return the disabled setting for this selection item.</p>
  141        */
  142       public boolean isItemDisabled() {
  143   
  144           return (Boolean) getStateHelper().eval(PropertyKeys.itemDisabled, false);
  145   
  146       }
  147   
  148       /**
  149        * <p>Set the disabled value for this selection item.</p>
  150        *
  151        * @param itemDisabled The new disabled flag
  152        */
  153       public void setItemDisabled(boolean itemDisabled) {
  154   
  155           getStateHelper().put(PropertyKeys.itemDisabled, itemDisabled);
  156   
  157       }
  158       
  159       /**
  160        * <p>Return the escape setting for the label of this selection item.</p>
  161        */
  162       public boolean isItemEscaped() {
  163   
  164           return (Boolean) getStateHelper().eval(PropertyKeys.itemEscaped, true);
  165   
  166       }
  167   
  168       /**
  169        * <p>Set the escape value for the label of this selection item.</p>
  170        *
  171        * @param itemEscaped The new disabled flag
  172        */
  173       public void setItemEscaped(boolean itemEscaped) {
  174   
  175           getStateHelper().put(PropertyKeys.itemEscaped, itemEscaped);
  176   
  177       }
  178       
  179   
  180       /**
  181        * <p>Return the localized label for this selection item.</p>
  182        */
  183       public String getItemLabel() {
  184   
  185           return (String) getStateHelper().eval(PropertyKeys.itemLabel);
  186   
  187       }
  188   
  189   
  190       /**
  191        * <p>Set the localized label for this selection item.</p>
  192        *
  193        * @param itemLabel The new localized label
  194        */
  195       public void setItemLabel(String itemLabel) {
  196   
  197           getStateHelper().put(PropertyKeys.itemLabel, itemLabel);
  198   
  199       }
  200   
  201   
  202       /**
  203        * <p>Return the server value for this selection item.</p>
  204        */
  205       public Object getItemValue() {
  206   
  207           return getStateHelper().eval(PropertyKeys.itemValue);
  208   
  209       }
  210   
  211   
  212       /**
  213        * <p>Set the server value for this selection item.</p>
  214        *
  215        * @param itemValue The new server value
  216        */
  217       public void setItemValue(Object itemValue) {
  218   
  219           getStateHelper().put(PropertyKeys.itemValue, itemValue);
  220   
  221       }
  222   
  223   
  224   
  225       /**
  226        * <p>Returns the <code>value</code> property of the
  227        * <code>UISelectItem</code>.</p>
  228        */
  229       public Object getValue() {
  230   
  231           return getStateHelper().eval(PropertyKeys.value);
  232   
  233       }
  234   
  235   
  236       /**
  237        * <p>Sets the <code>value</code> property of the
  238        * <code>UISelectItem</code>.</p>
  239        * 
  240        * @param value the new value
  241        */
  242       public void setValue(Object value) {
  243   
  244           getStateHelper().put(PropertyKeys.value,  value);
  245   
  246       }
  247       
  248       /** <p class="changed_added_2_0">Return the value of the
  249        * <code>noSelectionOption</code> property.  If the value of this
  250        * property is <code>true</code>, the system interprets the option
  251        * represented by this <code>UISelectItem</code> instance as
  252        * representing a "no selection" option.  See {@link
  253        * UISelectOne#validateValue} and {@link UISelectMany#validateValue}
  254        * for usage.</p>
  255        *
  256        * @since 2.0
  257        */
  258       public boolean isNoSelectionOption() {
  259   
  260           return (Boolean) getStateHelper().eval(PropertyKeys.noSelectionOption, false);
  261       }
  262   
  263       /**
  264        * <p class="changed_added_2_0">Set the value of the
  265        * <code>noSelectionOption</code> property.</p>
  266        *
  267        * @since 2.0
  268        */
  269       public void setNoSelectionOption(boolean noSelectionOption) {
  270   
  271           getStateHelper().put(PropertyKeys.noSelectionOption, noSelectionOption);
  272   
  273       }
  274   
  275   }

Home » Mojarra-2.0.1 » javax » faces » component » [javadoc | source]