View Javadoc

1   /**
2    * Copyright 2005-2011 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 edu.sampleu.demo.kitchensink;
17  
18  import org.kuali.rice.core.api.uif.RemotableAttributeField;
19  import org.kuali.rice.core.api.uif.RemotableSelect;
20  import org.kuali.rice.core.api.uif.RemotableTextInput;
21  import org.kuali.rice.krad.uif.container.Container;
22  import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl;
23  import org.kuali.rice.krad.uif.view.View;
24  
25  import java.util.ArrayList;
26  import java.util.HashMap;
27  import java.util.List;
28  import java.util.Map;
29  
30  /**
31   * Custom view helper service for demonstration (supports the kitchen sink)
32   *
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  public class UIfComponentsViewHelperServiceImpl extends ViewHelperServiceImpl {
36  
37      public List<RemotableAttributeField> retrieveRemoteFields(View view, Object model, Container container) {
38          List<RemotableAttributeField> remoteFields = new ArrayList<RemotableAttributeField>();
39  
40          // note this would generally invoke a remote service to get the list of fields
41          RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create("remoteField1");
42          builder.setLongLabel("Remote Field 1");
43  
44          RemotableTextInput.Builder controlBuilder = RemotableTextInput.Builder.create();
45          controlBuilder.setSize(30);
46          builder.setControl(controlBuilder);
47          remoteFields.add(builder.build());
48  
49          builder.setName("remoteField2");
50          builder.setLongLabel("Remote Field 2");
51          remoteFields.add(builder.build());
52  
53          controlBuilder.setSize(5);
54          builder.setName("remoteField3");
55          builder.setLongLabel("Remote Field 3");
56          remoteFields.add(builder.build());
57  
58          Map<String, String> options = new HashMap<String, String>();
59          options.put("Fruit", "Fruit");
60          options.put("Vegetables", "Vegetables");
61  
62          RemotableSelect.Builder selectBuilder = RemotableSelect.Builder.create(options);
63          builder.setName("remoteField4");
64          builder.setLongLabel("Remote Field 4");
65          builder.setControl(selectBuilder);
66          remoteFields.add(builder.build());
67  
68          return remoteFields;
69      }
70  
71  }