001 /** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.krad.demo.uif.options; 017 018 import org.kuali.rice.core.api.util.ConcreteKeyValue; 019 import org.kuali.rice.core.api.util.KeyValue; 020 import org.kuali.rice.krad.demo.uif.form.KradSampleAppForm; 021 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase; 022 import org.kuali.rice.krad.uif.view.ViewModel; 023 024 import java.util.ArrayList; 025 import java.util.List; 026 027 /** 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030 public class FoodKeyValuesFinder extends UifKeyValuesFinderBase { 031 032 @Override 033 public List<KeyValue> getKeyValues(ViewModel model) { 034 KradSampleAppForm testForm = (KradSampleAppForm) model; 035 036 List<KeyValue> options = new ArrayList<KeyValue>(); 037 038 //options would come from a db in a real scenario 039 if (testForm.getInputField4() == null || testForm.getInputField4().equals("Fruits")) { 040 options.add(new ConcreteKeyValue("Apples", "Apples")); 041 options.add(new ConcreteKeyValue("Bananas", "Bananas")); 042 options.add(new ConcreteKeyValue("Cherries", "Cherries")); 043 options.add(new ConcreteKeyValue("Oranges", "Oranges")); 044 options.add(new ConcreteKeyValue("Pears", "Pears")); 045 } else if (testForm.getInputField4().equals("Vegetables")) { 046 options.add(new ConcreteKeyValue("Beans", "Beans")); 047 options.add(new ConcreteKeyValue("Broccoli", "Broccoli")); 048 options.add(new ConcreteKeyValue("Cabbage", "Cabbage")); 049 options.add(new ConcreteKeyValue("Carrots", "Carrots")); 050 options.add(new ConcreteKeyValue("Celery", "Celery")); 051 options.add(new ConcreteKeyValue("Corn", "Corn")); 052 options.add(new ConcreteKeyValue("Peas", "Peas")); 053 } 054 055 return options; 056 } 057 058 }