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.labs.kitchensink.UifComponentsTestForm; 022 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase; 023 import org.kuali.rice.krad.uif.field.InputField; 024 import org.kuali.rice.krad.uif.view.ViewModel; 025 026 import java.util.ArrayList; 027 import java.util.List; 028 029 /** 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032 public class FoodKeyValuesFinder extends UifKeyValuesFinderBase { 033 034 @Override 035 public List<KeyValue> getKeyValues(ViewModel model) { 036 String foodType = null; 037 038 if (model instanceof KradSampleAppForm) { 039 KradSampleAppForm testForm = (KradSampleAppForm) model; 040 foodType = testForm.getInputField4(); 041 } else { 042 UifComponentsTestForm testForm = (UifComponentsTestForm) model; 043 foodType = testForm.getField88(); 044 } 045 046 List<KeyValue> options = new ArrayList<KeyValue>(); 047 048 //options would come from a db in a real scenario 049 if (foodType == null || foodType.equals("Fruits")) { 050 options.add(new ConcreteKeyValue("Apples", "Apples")); 051 options.add(new ConcreteKeyValue("Bananas", "Bananas")); 052 options.add(new ConcreteKeyValue("Cherries", "Cherries")); 053 options.add(new ConcreteKeyValue("Oranges", "Oranges")); 054 options.add(new ConcreteKeyValue("Pears", "Pears")); 055 } else if (foodType.equals("Vegetables")) { 056 options.add(new ConcreteKeyValue("Beans", "Beans")); 057 options.add(new ConcreteKeyValue("Broccoli", "Broccoli")); 058 options.add(new ConcreteKeyValue("Cabbage", "Cabbage")); 059 options.add(new ConcreteKeyValue("Carrots", "Carrots")); 060 options.add(new ConcreteKeyValue("Celery", "Celery")); 061 options.add(new ConcreteKeyValue("Corn", "Corn")); 062 options.add(new ConcreteKeyValue("Peas", "Peas")); 063 } 064 065 return options; 066 } 067 068 }