View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.control;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
21  
22  /**
23   * Represents a HTML Select control. Provides preset options for the User to
24   * choose from by a drop down
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  @BeanTags({@BeanTag(name = "dropdownControl-bean", parent = "Uif-DropdownControl"),
29          @BeanTag(name = "multiSelectControl-bean", parent = "Uif-MultiSelectControl")})
30  public class SelectControl extends MultiValueControlBase implements SizedControl {
31      private static final long serialVersionUID = 6443247954759096815L;
32  
33      private int size;
34      private boolean multiple;
35  
36      public SelectControl() {
37          size = 1;
38          multiple = false;
39      }
40  
41      /**
42       * Vertical size of the control. This determines how many options can be
43       * seen without using the control scoll bar. Defaults to 1
44       *
45       * @return size
46       */
47      @BeanTagAttribute(name="size")
48      public int getSize() {
49          return this.size;
50      }
51  
52      /**
53       * @see org.kuali.rice.krad.uif.control.SizedControl#setSize(int)
54       */
55      public void setSize(int size) {
56          this.size = size;
57      }
58  
59      /**
60       * Indicates whether multiple values can be selected. Defaults to false
61       * <p>
62       * If multiple is set to true, the underlying property must be of Array type
63       * </p>
64       *
65       * @return true if multiple values can be selected, false if only
66       *         one value can be selected
67       */
68      @BeanTagAttribute(name="multiple")
69      public boolean isMultiple() {
70          return this.multiple;
71      }
72  
73      /**
74       * Set whether multiple values can be selected
75       *
76       * @param multiple
77       */
78      public void setMultiple(boolean multiple) {
79          this.multiple = multiple;
80      }
81  
82      /**
83       * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
84       */
85      @Override
86      protected <T> void copyProperties(T component) {
87          super.copyProperties(component);
88          SelectControl selectControlCopy = (SelectControl) component;
89          selectControlCopy.setSize(this.getSize());
90          selectControlCopy.setMultiple(this.isMultiple());
91      }
92  }