View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by bobhurt on 9/6/12
16   */
17  package org.kuali.student.common.kitchensink;
18  
19  import org.kuali.rice.core.api.util.ConcreteKeyValue;
20  import org.kuali.rice.core.api.util.KeyValue;
21  import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
22  import org.kuali.rice.krad.uif.view.ViewModel;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * This class provides a mock implementation for a checkbox control's "optionsFinder" property.
29   *
30   * @author Kuali Student Team
31   */
32  public class KitchenSinkMockDwarfKeyValues extends UifKeyValuesFinderBase {
33  
34      public KitchenSinkMockDwarfKeyValues() {
35          // prevent addBlankOption from ever being set to true:
36          this.setAddBlankOption(false);
37      }
38      /**
39       * This is a fake implementation of a key value finder, normally this would make a request to
40       * a database to obtain the necessary values.  Used only for testing.
41       *
42       * @see org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase
43       */
44      @Override
45      public List<KeyValue> getKeyValues(ViewModel model) {
46          // NOTE: if the model isn't needed, the class can just extend KeyValuesBase
47          KitchenSinkForm form = (KitchenSinkForm)model;
48  
49          List<KeyValue> keyValues = new ArrayList<KeyValue>();
50          keyValues.add(new ConcreteKeyValue("1", "A dwarf named Bashful"));
51          keyValues.add(new ConcreteKeyValue("2", "A dwarf named Doc"));
52          keyValues.add(new ConcreteKeyValue("3", "A dwarf named Dopey"));
53          keyValues.add(new ConcreteKeyValue("4", "A dwarf named Grumpy"));
54          keyValues.add(new ConcreteKeyValue("5", "A dwarf named Happy"));
55          keyValues.add(new ConcreteKeyValue("6", "A dwarf named Sleepy"));
56          keyValues.add(new ConcreteKeyValue("7", "A dwarf named Sneezy"));
57          return keyValues;
58      }
59  
60  }