Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ViewHelperService |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2007 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 1.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/ecl1.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.service; | |
17 | ||
18 | import org.kuali.rice.krad.uif.container.CollectionGroup; | |
19 | import org.kuali.rice.krad.uif.container.View; | |
20 | import org.kuali.rice.krad.uif.core.Component; | |
21 | import org.kuali.rice.krad.uif.widget.Inquiry; | |
22 | import org.kuali.rice.krad.web.form.UifFormBase; | |
23 | ||
24 | import java.util.Map; | |
25 | ||
26 | /** | |
27 | * Provides methods for implementing the various phases of a <code>View</code> | |
28 | * | |
29 | * <ul> | |
30 | * <li>Initialize Phase: Invoked when the view is first requested to setup | |
31 | * necessary state</li> | |
32 | * </ul> | |
33 | * | |
34 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
35 | */ | |
36 | public interface ViewHelperService { | |
37 | ||
38 | /** | |
39 | * Populates the <code>View</code> properties from the given request | |
40 | * parameters | |
41 | * | |
42 | * <p> | |
43 | * The <code>View</code> instance is inspected for fields that have the | |
44 | * <code>RequestParameter</code> annotation and if corresponding parameters | |
45 | * are found in the request parameter map, the request value is used to set | |
46 | * the view property. The Map of parameter name/values that match are placed | |
47 | * in the view so they can be later retrieved to rebuild the view. Custom | |
48 | * <code>ViewServiceHelper</code> implementations can add additional | |
49 | * parameter key/value pairs to the returned map if necessary. | |
50 | * </p> | |
51 | * | |
52 | * @see org.kuali.rice.krad.uif.core.RequestParameter | |
53 | */ | |
54 | public void populateViewFromRequestParameters(View view, Map<String, String> parameters); | |
55 | ||
56 | /** | |
57 | * Performs the Initialization phase for the <code>View</code>. During this | |
58 | * phase each component of the tree is invoked to setup state based on the | |
59 | * configuration and request options. | |
60 | * | |
61 | * <p> | |
62 | * The initialize phase is only called once per <code>View</code> lifecycle | |
63 | * (when first requested) | |
64 | * </p> | |
65 | * | |
66 | * <p> | |
67 | * Note the <code>View</code> instance also contains the context Map that | |
68 | * was created based on the parameters sent to the view service | |
69 | * </p> | |
70 | * | |
71 | * @param view | |
72 | * - View instance that should be initialized | |
73 | */ | |
74 | public void performInitialization(View view); | |
75 | ||
76 | /** | |
77 | * Performs the Initialization phase for the given <code>Component</code> | |
78 | * | |
79 | * <p> | |
80 | * Can be called for component instances constructed via code or prototypes | |
81 | * to initialize the constructed component | |
82 | * </p> | |
83 | * | |
84 | * @param view | |
85 | * - view instance the component belongs to | |
86 | * @param component | |
87 | * - component instance that should be initialized | |
88 | */ | |
89 | public void performComponentInitialization(View view, Component component); | |
90 | ||
91 | /** | |
92 | * Executes the ApplyModel phase. During this phase each component of the | |
93 | * tree if invoked to setup any state based on the given model data | |
94 | * | |
95 | * <p> | |
96 | * Part of the view lifecycle that applies the model data to the view. | |
97 | * Should be called after the model has been populated before the view is | |
98 | * rendered. The main things that occur during this phase are: | |
99 | * <ul> | |
100 | * <li>Generation of dynamic fields (such as collection rows)</li> | |
101 | * <li>Execution of conditional logic (hidden, read-only, required settings | |
102 | * based on model values)</li> | |
103 | * </ul> | |
104 | * </p> | |
105 | * | |
106 | * <p> | |
107 | * The update phase can be called multiple times for the view's lifecycle | |
108 | * (typically only once per request) | |
109 | * </p> | |
110 | * | |
111 | * @param view | |
112 | * - View instance that the model should be applied to | |
113 | * @param model | |
114 | * - Top level object containing the data (could be the form or a | |
115 | * top level business object, dto) | |
116 | */ | |
117 | public void performApplyModel(View view, Object model); | |
118 | ||
119 | /** | |
120 | * The last phase before the view is rendered. Here final preparations can | |
121 | * be made based on the updated view state | |
122 | * | |
123 | * <p> | |
124 | * The finalize phase runs after the apply model phase and can be called | |
125 | * multiple times for the view's lifecylce (however typically only once per | |
126 | * request) | |
127 | * </p> | |
128 | * | |
129 | * | |
130 | * @param view | |
131 | * - view instance that should be finalized for rendering | |
132 | * @param model | |
133 | * - top level object containing the data | |
134 | */ | |
135 | public void performFinalize(View view, Object model); | |
136 | ||
137 | /** | |
138 | * Invoked when the add line action is chosen for a collection. The | |
139 | * collection path gives the full path to the collection that action was | |
140 | * selected for. Here validation can be performed on the line as well as | |
141 | * further processing on the line such as defaults. If the action is valid | |
142 | * the line should be added to the collection, otherwise errors should be | |
143 | * added to the global <code>MessageMap</code> | |
144 | * | |
145 | * @param view | |
146 | * - view instance that is being presented (the action was taken | |
147 | * on) | |
148 | * @param model | |
149 | * - Top level object containing the view data including the | |
150 | * collection and new line | |
151 | * @param collectionPath | |
152 | * - full path to the collection on the model | |
153 | */ | |
154 | public void processCollectionAddLine(View view, Object model, String collectionPath); | |
155 | ||
156 | /** | |
157 | * Invoked when the delete line action is chosen for a collection. The | |
158 | * collection path gives the full path to the collection that action was | |
159 | * selected for. Here validation can be performed to make sure the action is | |
160 | * allowed. If the action is valid the line should be deleted from the | |
161 | * collection, otherwise errors should be added to the global | |
162 | * <code>MessageMap</code> | |
163 | * | |
164 | * @param view | |
165 | * - view instance that is being presented (the action was taken | |
166 | * on) | |
167 | * @param model | |
168 | * - Top level object containing the view data including the | |
169 | * collection | |
170 | * @param collectionPath | |
171 | * - full path to the collection on the model | |
172 | * @param lineIndex | |
173 | * - index of the collection line that was selected for removal | |
174 | */ | |
175 | public void processCollectionDeleteLine(View view, Object model, String collectionPath, int lineIndex); | |
176 | ||
177 | /** | |
178 | * Invoked by the <code>Inquiry</code> widget to build the inquiry link | |
179 | * | |
180 | * <p> | |
181 | * Note this is used primarily for custom <code>Inquirable</code> | |
182 | * implementations to customize the inquiry class or parameters for an | |
183 | * inquiry. Instead of building the full inquiry link, implementations can | |
184 | * make a callback to | |
185 | * org.kuali.rice.krad.uif.widget.Inquiry.buildInquiryLink(Object, String, | |
186 | * Class<?>, Map<String, String>) given an inquiry class and parameters to | |
187 | * build the link field. | |
188 | * </p> | |
189 | * | |
190 | * @param dataObject | |
191 | * - parent object for the inquiry property | |
192 | * @param propertyName | |
193 | * - name of the property the inquiry is being built for | |
194 | * @param inquiry | |
195 | * - instance of the inquiry widget being built for the property | |
196 | */ | |
197 | public void buildInquiryLink(Object dataObject, String propertyName, Inquiry inquiry); | |
198 | ||
199 | /** | |
200 | * Applies default values configured for <code>AttributeField</code> | |
201 | * instances within the <code>View</code> to the given model | |
202 | * | |
203 | * @param view | |
204 | * - view containing attribute fields | |
205 | * @param model | |
206 | * - model instance to apply default values to | |
207 | */ | |
208 | public void applyDefaultValues(View view, UifFormBase model); | |
209 | ||
210 | /** | |
211 | * Applies configured default values for the line fields to the line | |
212 | * instance | |
213 | * | |
214 | * @param view | |
215 | * - view instance the collection line belongs to | |
216 | * @param model | |
217 | * - object containing the full view data | |
218 | * @param collectionGroup | |
219 | * - collection group component the line belongs to | |
220 | * @param line | |
221 | * - line instance to apply default values to | |
222 | */ | |
223 | public void applyDefaultValuesForCollectionLine(View view, Object model, CollectionGroup collectionGroup, | |
224 | Object line); | |
225 | ||
226 | /** | |
227 | * Performs the complete component lifecycle on the component passed in | |
228 | * | |
229 | * @param form | |
230 | * @param component | |
231 | */ | |
232 | public void performComponentLifecycle(UifFormBase form, Component component, String origId); | |
233 | } |