001 /** 002 * Copyright 2005-2011 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 edu.sampleu.travel.krad.controller; 017 018 import org.kuali.rice.core.api.uif.RemotableAttributeField; 019 import org.kuali.rice.core.api.uif.RemotableSelect; 020 import org.kuali.rice.core.api.uif.RemotableTextInput; 021 import org.kuali.rice.krad.uif.container.Container; 022 import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl; 023 import org.kuali.rice.krad.uif.view.View; 024 025 import java.util.ArrayList; 026 import java.util.HashMap; 027 import java.util.List; 028 import java.util.Map; 029 030 /** 031 * Custom view helper service for demonstration (supports the kitchen sink) 032 * 033 * @author Kuali Rice Team (rice.collab@kuali.org) 034 */ 035 public class UIfComponentsViewHelperServiceImpl extends ViewHelperServiceImpl { 036 037 public List<RemotableAttributeField> retrieveRemoteFields(View view, Object model, Container container) { 038 List<RemotableAttributeField> remoteFields = new ArrayList<RemotableAttributeField>(); 039 040 // note this would generally invoke a remote service to get the list of fields 041 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create("remoteField1"); 042 builder.setLongLabel("Remote Field 1"); 043 044 RemotableTextInput.Builder controlBuilder = RemotableTextInput.Builder.create(); 045 controlBuilder.setSize(30); 046 builder.setControl(controlBuilder); 047 remoteFields.add(builder.build()); 048 049 builder.setName("remoteField2"); 050 builder.setLongLabel("Remote Field 2"); 051 remoteFields.add(builder.build()); 052 053 controlBuilder.setSize(5); 054 builder.setName("remoteField3"); 055 builder.setLongLabel("Remote Field 3"); 056 remoteFields.add(builder.build()); 057 058 Map<String, String> options = new HashMap<String, String>(); 059 options.put("Fruit", "Fruit"); 060 options.put("Vegetables", "Vegetables"); 061 062 RemotableSelect.Builder selectBuilder = RemotableSelect.Builder.create(options); 063 builder.setName("remoteField4"); 064 builder.setLongLabel("Remote Field 4"); 065 builder.setControl(selectBuilder); 066 remoteFields.add(builder.build()); 067 068 return remoteFields; 069 } 070 071 }