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 org.kuali.rice.krad.uif.widget;
17
18 import org.kuali.rice.krad.uif.view.View;
19 import org.kuali.rice.krad.uif.component.BindingInfo;
20 import org.kuali.rice.krad.uif.component.Component;
21 import org.kuali.rice.krad.uif.field.InputField;
22 import org.kuali.rice.krad.uif.field.AttributeQuery;
23
24 /**
25 * Widget that provides dynamic select options to the user as they
26 * are entering the value (also known as auto-complete)
27 *
28 * <p>
29 * Widget is backed by an <code>AttributeQuery</code> that provides
30 * the configuration for executing a query server side that will retrieve
31 * the valid option values.
32 * </p>
33 *
34 * @author Kuali Rice Team (rice.collab@kuali.org)
35 */
36 public class Suggest extends WidgetBase {
37 private static final long serialVersionUID = 7373706855319347225L;
38
39 private AttributeQuery suggestQuery;
40 private String sourcePropertyName;
41
42 public Suggest() {
43 super();
44 }
45
46 /**
47 * The following actions are performed:
48 *
49 * <ul>
50 * <li>Adjusts the query field mappings on the query based on the binding configuration of the field</li>
51 * <li>TODO: determine query if render is true and query is not set</li>
52 * </ul>
53 *
54 * @see org.kuali.rice.krad.uif.component.ComponentBase#performFinalize(org.kuali.rice.krad.uif.view.View,
55 * java.lang.Object, org.kuali.rice.krad.uif.component.Component)
56 */
57 @Override
58 public void performFinalize(View view, Object model, Component parent) {
59 super.performFinalize(view, model, parent);
60
61 if (!isRender()) {
62 return;
63 }
64
65 InputField field = (InputField) parent;
66 BindingInfo bindingInfo = field.getBindingInfo();
67
68 // adjust from side on query field mapping to match parent fields path
69 suggestQuery.updateQueryFieldMapping(bindingInfo);
70 }
71
72 /**
73 * Attribute query instance the will be executed to provide
74 * the suggest options
75 *
76 * @return AttributeQuery
77 */
78 public AttributeQuery getSuggestQuery() {
79 return suggestQuery;
80 }
81
82 /**
83 * Setter for the suggest attribute query
84 *
85 * @param suggestQuery
86 */
87 public void setSuggestQuery(AttributeQuery suggestQuery) {
88 this.suggestQuery = suggestQuery;
89 }
90
91 /**
92 * Name of the property on the query result object that provides
93 * the options for the suggest, values from this field will be
94 * collected and sent back on the result to provide as suggest options
95 *
96 * @return String source property name
97 */
98 public String getSourcePropertyName() {
99 return sourcePropertyName;
100 }
101
102 /**
103 * Setter for the source property name
104 *
105 * @param sourcePropertyName
106 */
107 public void setSourcePropertyName(String sourcePropertyName) {
108 this.sourcePropertyName = sourcePropertyName;
109 }
110 }