1 /**
2 * Copyright 2005-2012 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.view;
17
18 import org.kuali.rice.krad.uif.UifConstants.ViewType;
19
20 import javax.servlet.http.HttpServletRequest;
21 import java.io.Serializable;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
25
26 /**
27 * Interface that must be implemented for clases the provide the backing data (model) for a {@link View}
28 *
29 * <p>
30 * Since the View relies on helper properties from the model it is necessary the backing object implement this
31 * interface. Note model objects can extend {@link org.kuali.rice.krad.web.form.UifFormBase} which implements
32 * this interface
33 * </p>
34 *
35 * @author Kuali Rice Team (rice.collab@kuali.org)
36 */
37 public interface ViewModel extends Serializable {
38
39 /**
40 * Called after Spring binds the request to the form and before the controller method is invoked
41 *
42 * @param request - request object containing the query parameters
43 */
44 public void postBind(HttpServletRequest request);
45
46
47 /**
48 * Unique Id for the <code>View</code> instance. This is specified for a
49 * view in its definition by setting the 'id' property.
50 *
51 * @return String view id
52 */
53 public String getViewId();
54
55 /**
56 * Setter for the unique view id
57 *
58 * @param viewId
59 */
60 public void setViewId(String viewId);
61
62 /**
63 * Name for the <code>View</code> instance. This is specified for a view in
64 * its definition by setting the 'id' property. The name is not necessary
65 * unique and cannot be used by itself to retrieve a view. Typically it is
66 * used with other parameters to identify a view with a certain type (view
67 * type)
68 *
69 * @return String view name
70 */
71 public String getViewName();
72
73 /**
74 * Setter for the view name
75 *
76 * @param viewName
77 */
78 public void setViewName(String viewName);
79
80 /**
81 * Name for the type of view being requested. This can be used to find
82 * <code>View</code> instances by request parameters (not necessary the
83 * unique id)
84 *
85 * @return String view type name
86 */
87 public ViewType getViewTypeName();
88
89 /**
90 * Setter for the view type name
91 *
92 * @param viewTypeName
93 */
94 public void setViewTypeName(ViewType viewTypeName);
95
96 /**
97 * View instance associated with the model. Used to render the user interface
98 *
99 * @return View
100 */
101 public View getView();
102
103 /**
104 * Setter for the view instance
105 *
106 * @param view
107 */
108 public void setView(View view);
109
110 /**
111 * View instance for the page that made a request. Since a new view instance
112 * gets initialized for each request before the controller logic is invoked,
113 * any state about the previous view is lost. This could be needed to read
114 * metadata from the view for such things as collection processing. When
115 * this is necessary the previous view instance can be retrieved
116 *
117 * @return View instance
118 */
119 public View getPostedView();
120
121 /**
122 * Setter for the previous view instance
123 *
124 * @param previousView
125 */
126 public void setPostedView(View previousView);
127
128 /**
129 * Id for the current page being displayed within the view
130 *
131 * @return String page id
132 */
133 public String getPageId();
134
135 /**
136 * Setter for the current page id
137 *
138 * @param pageId
139 */
140 public void setPageId(String pageId);
141
142 /**
143 * URL the form generated for the view should post to
144 *
145 * @return String form post URL
146 */
147 public String getFormPostUrl();
148
149 /**
150 * Setter for the form post URL
151 *
152 * @param formPostUrl
153 */
154 public void setFormPostUrl(String formPostUrl);
155
156 /**
157 * Map of parameters that was used to configured the <code>View</code>.
158 * Maintained on the form to rebuild the view on posts and session timeout
159 *
160 * @return Map<String, String> view parameters
161 * @see org.kuali.rice.krad.uif.view.View.getViewRequestParameters()
162 */
163 public Map<String, String> getViewRequestParameters();
164
165 /**
166 * Setter for the view's request parameter map
167 *
168 * @param viewRequestParameters
169 */
170 public void setViewRequestParameters(Map<String, String> viewRequestParameters);
171
172 /**
173 * List of fields that should be read only on the view
174 *
175 * <p>
176 * If the view being rendered supports request setting of read-only fields, the readOnlyFields request parameter
177 * can be sent to mark fields as read only that might not have been otherwise
178 * </p>
179 *
180 * <p>
181 * Note the paths specified should be the simple property names (not the full binding path). Therefore if the
182 * property name appears multiple times in the view, all instances will be set as read only
183 * </p>
184 *
185 * @return List<String> read only property names
186 * @see View#isSupportsRequestOverrideOfReadOnlyFields()
187 */
188 public List<String> getReadOnlyFieldsList();
189
190 /**
191 * Setter for the list of read only fields
192 *
193 * @param readOnlyFieldsList
194 */
195 public void setReadOnlyFieldsList(List<String> readOnlyFieldsList);
196
197 /**
198 * Holds instances for collection add lines. The key of the Map gives the
199 * collection name the line instance applies to, the Map value is an
200 * instance of the collection object class that holds the new line data
201 *
202 * @return Map<String, Object> new collection lines
203 */
204 public Map<String, Object> getNewCollectionLines();
205
206 /**
207 * Setter for the new collection lines Map
208 *
209 * @param newCollectionLines
210 */
211 public void setNewCollectionLines(Map<String, Object> newCollectionLines);
212
213 /**
214 * Map of parameters sent for the invoked action
215 *
216 * <p>
217 * Many times besides just setting the method to call actions need to send
218 * additional parameters. For instance the method being called might do a
219 * redirect, in which case the action needs to send parameters for the
220 * redirect URL. An example of this is redirecting to a <code>Lookup</code>
221 * view. In some cases the parameters that need to be sent conflict with
222 * properties already on the form, and putting all the action parameters as
223 * form properties would grow massive (in addition to adds an additional
224 * step from the XML config). So this general map solves those issues.
225 * </p>
226 *
227 * @return Map<String, String> action parameters
228 */
229 public Map<String, String> getActionParameters();
230
231 /**
232 * Setter for the action parameters map
233 *
234 * @param actionParameters
235 */
236 public void setActionParameters(Map<String, String> actionParameters);
237
238 /**
239 * Map that is populated from the component state maintained on the client
240 *
241 * <p>
242 * Used when a request is made that refreshes part of the view. The current state for components (which
243 * have state that can be changed on the client), is populated into this map which is then used by the
244 * <code>ViewHelperService</code> to update the components so that the state is maintained when they render.
245 * </p>
246 *
247 * @return Map<String, Object> map where key is name of property or component id, and value is the property
248 * value or another map of component key/value pairs
249 */
250 public Map<String, Object> getClientStateForSyncing();
251
252 /**
253 * Holds Set of String identifiers for lines that were selected in a collection
254 *
255 * <p>
256 * When the select field is enabled for a <code>CollectionGroup</code>, the framework will be
257 * default bind the selected identifier strings to this property. The key of the map uniquely identifies the
258 * collection by the full binding path to the collection, and the value is a set of Strings for the checked
259 * lines.
260 * </p>
261 *
262 * @return Map<String, Set<String>> map of collections and their selected lines
263 * @see org.kuali.rice.krad.service.DataObjectMetaDataService#getDataObjectIdentifierString(java.lang.Object)
264 */
265 public Map<String, Set<String>> getSelectedCollectionLines();
266
267 /**
268 * Setter for the map that holds selected collection lines
269 *
270 * @param selectedCollectionLines
271 */
272 public void setSelectedCollectionLines(Map<String, Set<String>> selectedCollectionLines);
273
274 /**
275 * Indicates whether the form has had default values from the configured
276 * <code>View</code> applied. This happens only once for each form instance
277 *
278 * @return boolean true if default values have been applied, false if not
279 */
280 public boolean isDefaultsApplied();
281
282 /**
283 * Setter for the defaults applied indicator
284 *
285 * @param defaultsApplied
286 */
287 public void setDefaultsApplied(boolean defaultsApplied);
288
289 /**
290 * Script that will run on render (view or component) for generating growl messages
291 *
292 * @return String JS growl script
293 */
294 public String getGrowlScript();
295
296 /**
297 * Setter for the script that generates growls on render
298 *
299 * @param growlScript
300 */
301 public void setGrowlScript(String growlScript);
302
303 /**
304 * Script that will run on render (view or component) for a lightbox
305 *
306 * @return String JS lightbox script
307 */
308 public String getLightboxScript();
309
310 /**
311 * Setter for the script that generates a lightbox on render
312 *
313 * @param lightboxScript
314 */
315 public void setLightboxScript(String lightboxScript);
316
317 /**
318 * Gets the state. This is the default location for state on KRAD forms.
319 *
320 * @return the state
321 */
322 public String getState();
323
324 /**
325 * Set the state
326 *
327 * @param state
328 */
329 public void setState(String state);
330
331 /**
332 * Gets the ajaxRequest. Indicates if the request is coming through an ajax call.
333 *
334 * @return
335 */
336 public boolean isAjaxRequest();
337
338 /**
339 * Set the ajaxRequest
340 *
341 * @param ajaxRequest
342 */
343 public void setAjaxRequest(boolean ajaxRequest);
344
345 /**
346 * Gets the return type for the ajax call. Used to determine the handler for the request
347 *
348 * @return
349 */
350 public String getAjaxReturnType();
351
352 /**
353 * Set the ajaxReturnType
354 *
355 * @param ajaxReturnType
356 */
357 public void setAjaxReturnType(String ajaxReturnType);
358
359 }