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  
21  /**
22   * OptionListControl is used for listing out options from an option finder or options list.  This control can show all
23   * items in the options or it can show only the selected options (if backed by a propertyName).  One use case for this
24   * control is to use it in combination with UifKeyValueLocation to provide a list of locations retrieved through a
25   * KeyValuesFinder.
26   */
27  @BeanTag(name = "optionListControl-bean", parent = "Uif-OptionListControl")
28  public class OptionListControl extends MultiValueControlBase {
29      private String itemCssClass;
30      private String selectedItemCssClass;
31      private boolean showOnlySelected;
32  
33      /**
34       * The item css class to add to each li element of the list
35       *
36       * @return the item css class
37       */
38      @BeanTagAttribute(name = "itemCssClass")
39      public String getItemCssClass() {
40          return itemCssClass;
41      }
42  
43      /**
44       * Set the itemCssClass
45       *
46       * @param itemCssClass
47       */
48      public void setItemCssClass(String itemCssClass) {
49          this.itemCssClass = itemCssClass;
50      }
51  
52      /**
53       * When true, only show the "selected" options (items which match a value in the property of the field).  Otherwise,
54       * show all options.
55       *
56       * @return true if only showing selected options, otherwise show all
57       */
58      @BeanTagAttribute(name = "showOnlySelected")
59      public boolean isShowOnlySelected() {
60          return showOnlySelected;
61      }
62  
63      /**
64       * Set the showOnlySelected flag
65       *
66       * @param showOnlySelected
67       */
68      public void setShowOnlySelected(boolean showOnlySelected) {
69          this.showOnlySelected = showOnlySelected;
70      }
71  
72      /**
73       * The css class to add to each item of the list which matches a value in the property
74       *
75       * @return the selected item css class
76       */
77      @BeanTagAttribute(name = "selectedItemCssClass")
78      public String getSelectedItemCssClass() {
79          return selectedItemCssClass;
80      }
81  
82      /**
83       * Set the selectedItemCssClass
84       *
85       * @param selectedItemCssClass
86       */
87      public void setSelectedItemCssClass(String selectedItemCssClass) {
88          this.selectedItemCssClass = selectedItemCssClass;
89      }
90  
91      /**
92       * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
93       */
94      @Override
95      protected <T> void copyProperties(T component) {
96          super.copyProperties(component);
97          OptionListControl optionListControlCopy = (OptionListControl) component;
98          optionListControlCopy.setItemCssClass(this.getItemCssClass());
99          optionListControlCopy.setSelectedItemCssClass(this.getSelectedItemCssClass());
100         optionListControlCopy.setShowOnlySelected(this.isShowOnlySelected());
101     }
102 }