1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.kitchensink;
17
18 import org.kuali.rice.core.api.search.SearchOperator;
19 import org.kuali.rice.core.api.uif.RemotableAttributeField;
20 import org.kuali.rice.core.api.uif.RemotableSelect;
21 import org.kuali.rice.core.api.uif.RemotableTextInput;
22 import org.kuali.rice.krad.demo.travel.account.TravelAccount;
23 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
24 import org.kuali.rice.krad.uif.container.Container;
25 import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl;
26 import org.kuali.rice.krad.uif.view.View;
27
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37
38 public class UIfComponentsViewHelperServiceImpl extends ViewHelperServiceImpl {
39
40 public List<RemotableAttributeField> retrieveRemoteFields(View view, Object model, Container container) {
41 List<RemotableAttributeField> remoteFields = new ArrayList<RemotableAttributeField>();
42
43
44 RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create("remoteField1");
45 builder.setLongLabel("Remote Field 1");
46
47 RemotableTextInput.Builder controlBuilder = RemotableTextInput.Builder.create();
48 controlBuilder.setSize(30);
49 builder.setControl(controlBuilder);
50 remoteFields.add(builder.build());
51
52 builder.setName("remoteField2");
53 builder.setLongLabel("Remote Field 2");
54 remoteFields.add(builder.build());
55
56 controlBuilder.setSize(5);
57 builder.setName("remoteField3");
58 builder.setLongLabel("Remote Field 3");
59 remoteFields.add(builder.build());
60
61 Map<String, String> options = new HashMap<String, String>();
62 options.put("Fruit", "Fruit");
63 options.put("Vegetables", "Vegetables");
64
65 RemotableSelect.Builder selectBuilder = RemotableSelect.Builder.create(options);
66 builder.setName("remoteField4");
67 builder.setLongLabel("Remote Field 4");
68 builder.setControl(selectBuilder);
69 remoteFields.add(builder.build());
70
71 return remoteFields;
72 }
73
74 public List<TravelAccount> retrieveTravelAccounts(String term) {
75 List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
76
77 Map<String, String> lookupCriteria = new HashMap<String, String>();
78 lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
79
80 matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
81 TravelAccount.class, lookupCriteria);
82
83 return matchingAccounts;
84 }
85
86 public List<TravelAccount> retrieveTravelAccountsBySubAcct(String subAccount, String term) {
87 List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
88
89 Map<String, String> lookupCriteria = new HashMap<String, String>();
90 lookupCriteria.put("subAccount", subAccount);
91 lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
92
93 matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
94 TravelAccount.class, lookupCriteria);
95
96 return matchingAccounts;
97 }
98
99
100
101 }