Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
View |
|
| 1.1951219512195121;1.195 |
1 | /* | |
2 | * Copyright 2007 The Kuali Foundation Licensed under the Educational Community | |
3 | * License, Version 1.0 (the "License"); you may not use this file except in | |
4 | * compliance with the License. You may obtain a copy of the License at | |
5 | * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law | |
6 | * or agreed to in writing, software distributed under the License is | |
7 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
8 | * KIND, either express or implied. See the License for the specific language | |
9 | * governing permissions and limitations under the License. | |
10 | */ | |
11 | package org.kuali.rice.krad.uif.container; | |
12 | ||
13 | import java.util.ArrayList; | |
14 | import java.util.HashMap; | |
15 | import java.util.HashSet; | |
16 | import java.util.Iterator; | |
17 | import java.util.List; | |
18 | import java.util.Map; | |
19 | import java.util.Set; | |
20 | ||
21 | import org.apache.commons.lang.StringUtils; | |
22 | import org.kuali.rice.krad.service.DataObjectMetaDataService; | |
23 | import org.kuali.rice.krad.service.KRADServiceLocatorWeb; | |
24 | import org.kuali.rice.krad.uif.UifConstants; | |
25 | import org.kuali.rice.krad.uif.UifConstants.ViewStatus; | |
26 | import org.kuali.rice.krad.uif.UifConstants.ViewType; | |
27 | import org.kuali.rice.krad.uif.authorization.Authorizer; | |
28 | import org.kuali.rice.krad.uif.authorization.PresentationController; | |
29 | import org.kuali.rice.krad.uif.core.BindingInfo; | |
30 | import org.kuali.rice.krad.uif.core.Component; | |
31 | import org.kuali.rice.krad.uif.core.ReferenceCopy; | |
32 | import org.kuali.rice.krad.uif.core.RequestParameter; | |
33 | import org.kuali.rice.krad.uif.field.LinkField; | |
34 | import org.kuali.rice.krad.uif.service.ViewHelperService; | |
35 | import org.kuali.rice.krad.uif.util.BooleanMap; | |
36 | import org.kuali.rice.krad.uif.util.ClientValidationUtils; | |
37 | import org.kuali.rice.krad.uif.util.ViewModelUtils; | |
38 | import org.kuali.rice.krad.uif.widget.BreadCrumbs; | |
39 | import org.kuali.rice.krad.uif.widget.GrowlsWidget; | |
40 | import org.kuali.rice.krad.util.ObjectUtils; | |
41 | import org.kuali.rice.krad.web.spring.UifControllerHandlerInterceptor; | |
42 | ||
43 | /** | |
44 | * Root of the component tree which encompasses a set of related | |
45 | * <code>GroupContainer</code> instances tied together with a common page layout | |
46 | * and navigation. | |
47 | * <p> | |
48 | * The <code>View</code> component ties together all the components and | |
49 | * configuration of the User Interface for a piece of functionality. In Rice | |
50 | * applications the view is typically associated with a <code>Document</code> | |
51 | * instance. | |
52 | * </p> | |
53 | * <p> | |
54 | * The view template lays out the common header, footer, and navigation for the | |
55 | * related pages. In addition the view renders the HTML head element bringing in | |
56 | * common script files and style sheets, along with optionally rendering a form | |
57 | * element for pages that need to post data back to the server. | |
58 | * </p> | |
59 | * <p> | |
60 | * Configuration of UIF features such as model validation is also done through | |
61 | * the <code>View</code> | |
62 | * </p> | |
63 | * | |
64 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
65 | */ | |
66 | public class View extends ContainerBase { | |
67 | private static final long serialVersionUID = -1220009725554576953L; | |
68 | ||
69 | private String viewName; | |
70 | ||
71 | // Breadcrumbs | |
72 | private BreadCrumbs breadcrumbs; | |
73 | private String viewLabelFieldPropertyName; | |
74 | private BindingInfo viewLabelFieldBindingInfo; | |
75 | private String appendOption; | |
76 | ||
77 | // Growls support | |
78 | private GrowlsWidget growlsWidget; | |
79 | private boolean growlMessagingEnabled; | |
80 | ||
81 | private String entryPageId; | |
82 | ||
83 | @RequestParameter | |
84 | private String currentPageId; | |
85 | ||
86 | private NavigationGroup navigation; | |
87 | ||
88 | private Class<?> formClass; | |
89 | private String defaultBindingObjectPath; | |
90 | private Map<String, Class<?>> abstractTypeClasses; | |
91 | ||
92 | private List<String> additionalScriptFiles; | |
93 | private List<String> additionalCssFiles; | |
94 | ||
95 | private String viewTypeName; | |
96 | private Class<? extends ViewHelperService> viewHelperServiceClassName; | |
97 | ||
98 | private String viewStatus; | |
99 | private ViewIndex viewIndex; | |
100 | private Map<String, String> viewRequestParameters; | |
101 | ||
102 | private Class<? extends PresentationController> presentationControllerClass; | |
103 | private Class<? extends Authorizer> authorizerClass; | |
104 | ||
105 | private BooleanMap actionFlags; | |
106 | private BooleanMap editModes; | |
107 | ||
108 | private Map<String, String> expressionVariables; | |
109 | ||
110 | private boolean singlePageView; | |
111 | private PageGroup page; | |
112 | ||
113 | private List<? extends Group> items; | |
114 | ||
115 | private LinkField viewMenuLink; | |
116 | private String viewMenuGrouping; | |
117 | ||
118 | private boolean validateDirty; | |
119 | private boolean translateCodes; | |
120 | ||
121 | @RequestParameter | |
122 | private boolean dialogMode; | |
123 | ||
124 | @RequestParameter | |
125 | private String returnTarget; | |
126 | ||
127 | @ReferenceCopy | |
128 | private ViewHelperService viewHelperService; | |
129 | ||
130 | 0 | public View() { |
131 | 0 | dialogMode = false; |
132 | 0 | singlePageView = false; |
133 | 0 | translateCodes = false; |
134 | 0 | viewTypeName = ViewType.DEFAULT; |
135 | 0 | viewStatus = UifConstants.ViewStatus.CREATED; |
136 | ||
137 | 0 | additionalScriptFiles = new ArrayList<String>(); |
138 | 0 | additionalCssFiles = new ArrayList<String>(); |
139 | 0 | items = new ArrayList<Group>(); |
140 | 0 | abstractTypeClasses = new HashMap<String, Class<?>>(); |
141 | 0 | viewRequestParameters = new HashMap<String, String>(); |
142 | 0 | expressionVariables = new HashMap<String, String>(); |
143 | 0 | } |
144 | ||
145 | /** | |
146 | * The following initialization is performed: | |
147 | * <ul> | |
148 | * <li>If a single paged view, set items in page group and put the page in | |
149 | * the items list</li> | |
150 | * <li>If current page id is not set, it is set to the configured entry page | |
151 | * or first item in list id</li> | |
152 | * </ul> | |
153 | * | |
154 | * @see org.kuali.rice.krad.uif.container.ContainerBase#performInitialization(org.kuali.rice.krad.uif.container.View) | |
155 | */ | |
156 | @SuppressWarnings("unchecked") | |
157 | @Override | |
158 | public void performInitialization(View view) { | |
159 | 0 | super.performInitialization(view); |
160 | ||
161 | // populate items on page for single paged view | |
162 | 0 | if (singlePageView) { |
163 | 0 | if (page != null) { |
164 | 0 | page.setItems(new ArrayList<Group>(items)); |
165 | ||
166 | // reset the items list to include the one page | |
167 | 0 | items = new ArrayList<Group>(); |
168 | 0 | ((List<Group>) items).add(page); |
169 | } else { | |
170 | 0 | throw new RuntimeException("For single paged views the page Group must be set."); |
171 | } | |
172 | } | |
173 | ||
174 | // set the entry page | |
175 | 0 | if (StringUtils.isNotBlank(entryPageId)) { |
176 | 0 | currentPageId = entryPageId; |
177 | } else { | |
178 | 0 | Group firstPageGroup = getItems().get(0); |
179 | 0 | currentPageId = firstPageGroup.getId(); |
180 | } | |
181 | 0 | } |
182 | ||
183 | /** | |
184 | * This method is used to determine what property name is to be used for | |
185 | * view label appendage, called before the generation of | |
186 | * history/breadcrumb/title, but cannot be called from performInitialize | |
187 | * because the abstractTypeClasses map may not be populated before | |
188 | * super.performInitialize is called from a view child class (required for | |
189 | * ViewModelUtils#getPropertyType determination used in this method) | |
190 | * Currently called from UifControllerHandlerInterceptor... | |
191 | * | |
192 | * @see View#setViewLabelFieldPropertyName(String) | |
193 | * @see View#setViewLabelFieldBindingInfo(BindingInfo) | |
194 | * @see ViewModelUtils#getPropertyType | |
195 | * @see UifControllerHandlerInterceptor#postHandle | |
196 | */ | |
197 | public void determineViewLabelPropertyName() { | |
198 | // We have binding info but a custom viewLabelFieldPropertyName is set | |
199 | 0 | if (viewLabelFieldBindingInfo != null && StringUtils.isNotBlank(viewLabelFieldPropertyName)) { |
200 | 0 | viewLabelFieldBindingInfo.setDefaults(this, viewLabelFieldPropertyName); |
201 | } | |
202 | // Nothing is preset, auto determine title | |
203 | 0 | else if (viewLabelFieldBindingInfo == null && StringUtils.isBlank(viewLabelFieldPropertyName)) { |
204 | Class<?> doClass; | |
205 | 0 | if (StringUtils.isNotBlank(this.getDefaultBindingObjectPath())) { |
206 | 0 | doClass = ViewModelUtils.getPropertyType(this, this.getDefaultBindingObjectPath()); |
207 | } else { | |
208 | 0 | doClass = this.getFormClass(); |
209 | } | |
210 | 0 | DataObjectMetaDataService mds = KRADServiceLocatorWeb.getDataObjectMetaDataService(); |
211 | 0 | if (doClass != null) { |
212 | 0 | String title = mds.getTitleAttribute(doClass); |
213 | 0 | viewLabelFieldPropertyName = title; |
214 | } | |
215 | } | |
216 | // else assumption is to use whatever is in viewLabelFieldBindingInfo or | |
217 | // viewLabelFieldPropertyName | |
218 | 0 | } |
219 | ||
220 | /** | |
221 | * Perform finalize here adds to its document ready script the | |
222 | * setupValidator js function for setting up the validator for this view. | |
223 | * | |
224 | * @see org.kuali.rice.krad.uif.container.ContainerBase#performFinalize(org.kuali.rice.krad.uif.container.View, | |
225 | * java.lang.Object, org.kuali.rice.krad.uif.core.Component) | |
226 | */ | |
227 | @Override | |
228 | public void performFinalize(View view, Object model, Component parent) { | |
229 | 0 | super.performFinalize(view, model, parent); |
230 | ||
231 | 0 | String prefixScript = ""; |
232 | 0 | if (this.getOnDocumentReadyScript() != null) { |
233 | 0 | prefixScript = this.getOnDocumentReadyScript(); |
234 | } | |
235 | 0 | this.setOnDocumentReadyScript(prefixScript + "jQuery.extend(jQuery.validator.messages, " + |
236 | ClientValidationUtils.generateValidatorMessagesOption() + ");"); | |
237 | 0 | } |
238 | ||
239 | /** | |
240 | * @see org.kuali.rice.krad.uif.core.ComponentBase#getNestedComponents() | |
241 | */ | |
242 | @Override | |
243 | public List<Component> getNestedComponents() { | |
244 | 0 | List<Component> components = super.getNestedComponents(); |
245 | ||
246 | 0 | components.add(navigation); |
247 | ||
248 | 0 | return components; |
249 | } | |
250 | ||
251 | /** | |
252 | * @see org.kuali.rice.krad.web.view.container.ContainerBase#getSupportedComponents() | |
253 | */ | |
254 | @Override | |
255 | public Set<Class<? extends Component>> getSupportedComponents() { | |
256 | 0 | Set<Class<? extends Component>> supportedComponents = new HashSet<Class<? extends Component>>(); |
257 | 0 | supportedComponents.add(Group.class); |
258 | ||
259 | 0 | return supportedComponents; |
260 | } | |
261 | ||
262 | /** | |
263 | * @see org.kuali.rice.krad.uif.core.Component#getComponentTypeName() | |
264 | */ | |
265 | @Override | |
266 | public String getComponentTypeName() { | |
267 | 0 | return "view"; |
268 | } | |
269 | ||
270 | /** | |
271 | * Iterates through the contained page items and returns the Page that | |
272 | * matches the set current page id | |
273 | * | |
274 | * @return Page instance | |
275 | */ | |
276 | public PageGroup getCurrentPage() { | |
277 | 0 | for (Iterator<? extends Group> iterator = this.getItems().iterator(); iterator.hasNext(); ) { |
278 | 0 | Group pageGroup = iterator.next(); |
279 | 0 | if (pageGroup.getId().equals(getCurrentPageId())) { |
280 | 0 | return (PageGroup) pageGroup; |
281 | } | |
282 | 0 | } |
283 | ||
284 | 0 | return null; |
285 | } | |
286 | ||
287 | /** | |
288 | * View name provides an identifier for a view within a type. That is if a | |
289 | * set of <code>View</code> instances have the same values for the | |
290 | * properties that are used to retrieve them by their type, the name can be | |
291 | * given to further qualify the view that should be retrieved. | |
292 | * <p> | |
293 | * A view type like the <code>LookupView</code> might have several views for | |
294 | * the same object class, but one that is the 'default' lookup and another | |
295 | * that is the 'advanced' lookup. Therefore the name on the first could be | |
296 | * set to 'default', and likewise the name for the second 'advanced'. | |
297 | * </p> | |
298 | * | |
299 | * @return String name of view | |
300 | */ | |
301 | public String getViewName() { | |
302 | 0 | return this.viewName; |
303 | } | |
304 | ||
305 | /** | |
306 | * Setter for the view's name | |
307 | * | |
308 | * @param viewName | |
309 | */ | |
310 | public void setViewName(String viewName) { | |
311 | 0 | this.viewName = viewName; |
312 | 0 | } |
313 | ||
314 | /** | |
315 | * Specifies what page should be rendered by default. This is the page that | |
316 | * will be rendered when the <code>View</code> is first rendered or when the | |
317 | * current page is not set | |
318 | * | |
319 | * @return String id of the page to render by default | |
320 | */ | |
321 | public String getEntryPageId() { | |
322 | 0 | return this.entryPageId; |
323 | } | |
324 | ||
325 | /** | |
326 | * Setter for default Page id | |
327 | * | |
328 | * @param entryPageId | |
329 | */ | |
330 | public void setEntryPageId(String entryPageId) { | |
331 | 0 | this.entryPageId = entryPageId; |
332 | 0 | } |
333 | ||
334 | /** | |
335 | * The id for the page within the view that should be displayed in the UI. | |
336 | * Other pages of the view will not be rendered | |
337 | * | |
338 | * @return String id of the page that should be displayed | |
339 | */ | |
340 | public String getCurrentPageId() { | |
341 | 0 | return this.currentPageId; |
342 | } | |
343 | ||
344 | /** | |
345 | * Setter for the page id to display | |
346 | * | |
347 | * @param currentPageId | |
348 | */ | |
349 | public void setCurrentPageId(String currentPageId) { | |
350 | 0 | this.currentPageId = currentPageId; |
351 | 0 | } |
352 | ||
353 | /** | |
354 | * <code>NavigationGroup</code> instance for the <code>View</code> | |
355 | * <p> | |
356 | * Provides configuration necessary to render the navigation. This includes | |
357 | * navigation items in addition to configuration for the navigation | |
358 | * renderer. | |
359 | * </p> | |
360 | * | |
361 | * @return NavigationGroup | |
362 | */ | |
363 | public NavigationGroup getNavigation() { | |
364 | 0 | return this.navigation; |
365 | } | |
366 | ||
367 | /** | |
368 | * Setter for the View's <code>NavigationGroup</code> | |
369 | * | |
370 | * @param navigation | |
371 | */ | |
372 | public void setNavigation(NavigationGroup navigation) { | |
373 | 0 | this.navigation = navigation; |
374 | 0 | } |
375 | ||
376 | /** | |
377 | * Class of the Form that should be used with the <code>View</code> | |
378 | * instance. The form is the top level object for all the view's data and is | |
379 | * used to present and accept data in the user interface. All form classes | |
380 | * should extend UifFormBase | |
381 | * | |
382 | * @return Class<?> class for the view's form | |
383 | * @see org.kuali.rice.krad.web.spring.form.UifFormBase | |
384 | */ | |
385 | public Class<?> getFormClass() { | |
386 | 0 | return this.formClass; |
387 | } | |
388 | ||
389 | /** | |
390 | * Setter for the form class | |
391 | * | |
392 | * @param formClass | |
393 | */ | |
394 | public void setFormClass(Class<?> formClass) { | |
395 | 0 | this.formClass = formClass; |
396 | 0 | } |
397 | ||
398 | /** | |
399 | * For <code>View</code> types that work primarily with one nested object of | |
400 | * the form (for instance document, or bo) the default binding object path | |
401 | * can be set for each of the views <code>DataBinding</code> components. If | |
402 | * the component does not set its own binding object path it will inherit | |
403 | * the default | |
404 | * | |
405 | * @return String binding path to the object from the form | |
406 | * @see org.kuali.rice.krad.uif.BindingInfo.getBindingObjectPath() | |
407 | */ | |
408 | public String getDefaultBindingObjectPath() { | |
409 | 0 | return this.defaultBindingObjectPath; |
410 | } | |
411 | ||
412 | /** | |
413 | * Setter for the default binding object path to use for the view | |
414 | * | |
415 | * @param defaultBindingObjectPath | |
416 | */ | |
417 | public void setDefaultBindingObjectPath(String defaultBindingObjectPath) { | |
418 | 0 | this.defaultBindingObjectPath = defaultBindingObjectPath; |
419 | 0 | } |
420 | ||
421 | /** | |
422 | * Configures the concrete classes that will be used for properties in the | |
423 | * form object graph that have an abstract or interface type | |
424 | * <p> | |
425 | * For properties that have an abstract or interface type, it is not | |
426 | * possible to perform operations like getting/settings property values and | |
427 | * getting information from the dictionary. When these properties are | |
428 | * encountered in the object graph, this <code>Map</code> will be consulted | |
429 | * to determine the concrete type to use. | |
430 | * </p> | |
431 | * <p> | |
432 | * e.g. Suppose we have a property document.accountingLine.accountNumber and | |
433 | * the accountingLine property on the document instance has an interface | |
434 | * type 'AccountingLine'. We can then put an entry into this map with key | |
435 | * 'document.accountingLine', and value | |
436 | * 'org.kuali.rice.sampleapp.TravelAccountingLine'. When getting the | |
437 | * property type or an entry from the dictionary for accountNumber, the | |
438 | * TravelAccountingLine class will be used. | |
439 | * </p> | |
440 | * | |
441 | * @return Map<String, Class> of class implementations keyed by path | |
442 | */ | |
443 | public Map<String, Class<?>> getAbstractTypeClasses() { | |
444 | 0 | return this.abstractTypeClasses; |
445 | } | |
446 | ||
447 | /** | |
448 | * Setter for the Map of class implementations keyed by path | |
449 | * | |
450 | * @param abstractTypeClasses | |
451 | */ | |
452 | public void setAbstractTypeClasses(Map<String, Class<?>> abstractTypeClasses) { | |
453 | 0 | this.abstractTypeClasses = abstractTypeClasses; |
454 | 0 | } |
455 | ||
456 | /** | |
457 | * Declares additional script files that should be included with the | |
458 | * <code>View</code>. These files are brought into the HTML page along with | |
459 | * common script files configured for the Rice application. Each entry | |
460 | * contain the path to the CSS file, either a relative path, path from web | |
461 | * root, or full URI | |
462 | * <p> | |
463 | * e.g. '/krad/scripts/myScript.js', '../scripts/myScript.js', | |
464 | * 'http://my.edu/web/myScript.js' | |
465 | * </p> | |
466 | * | |
467 | * @return List<String> script file locations | |
468 | */ | |
469 | public List<String> getAdditionalScriptFiles() { | |
470 | 0 | return this.additionalScriptFiles; |
471 | } | |
472 | ||
473 | /** | |
474 | * Setter for the List of additional script files to included with the | |
475 | * <code>View</code> | |
476 | * | |
477 | * @param additionalScriptFiles | |
478 | */ | |
479 | public void setAdditionalScriptFiles(List<String> additionalScriptFiles) { | |
480 | 0 | this.additionalScriptFiles = additionalScriptFiles; |
481 | 0 | } |
482 | ||
483 | /** | |
484 | * Declares additional CSS files that should be included with the | |
485 | * <code>View</code>. These files are brought into the HTML page along with | |
486 | * common CSS files configured for the Rice application. Each entry should | |
487 | * contain the path to the CSS file, either a relative path, path from web | |
488 | * root, or full URI | |
489 | * <p> | |
490 | * e.g. '/krad/css/stacked-view.css', '../css/stacked-view.css', | |
491 | * 'http://my.edu/web/stacked-view.css' | |
492 | * </p> | |
493 | * | |
494 | * @return List<String> CSS file locations | |
495 | */ | |
496 | public List<String> getAdditionalCssFiles() { | |
497 | 0 | return this.additionalCssFiles; |
498 | } | |
499 | ||
500 | /** | |
501 | * Setter for the List of additional CSS files to included with the | |
502 | * <code>View</code> | |
503 | * | |
504 | * @param additionalCssFiles | |
505 | */ | |
506 | public void setAdditionalCssFiles(List<String> additionalCssFiles) { | |
507 | 0 | this.additionalCssFiles = additionalCssFiles; |
508 | 0 | } |
509 | ||
510 | public boolean isDialogMode() { | |
511 | 0 | return this.dialogMode; |
512 | } | |
513 | ||
514 | public void setDialogMode(boolean dialogMode) { | |
515 | 0 | this.dialogMode = dialogMode; |
516 | 0 | } |
517 | ||
518 | /** | |
519 | * @param returnTarget the returnTarget to set | |
520 | */ | |
521 | public void setReturnTarget(String returnTarget) { | |
522 | 0 | this.returnTarget = returnTarget; |
523 | 0 | } |
524 | ||
525 | /** | |
526 | * @return the returnTarget | |
527 | */ | |
528 | public String getReturnTarget() { | |
529 | 0 | return returnTarget; |
530 | } | |
531 | ||
532 | /** | |
533 | * View type name the view is associated with | |
534 | * <p> | |
535 | * Views that share common features and functionality can be grouped by the | |
536 | * view type. Usually view types extend the <code>View</code> class to | |
537 | * provide additional configuration and to set defaults. View types can also | |
538 | * implement the <code>ViewTypeService</code> to add special indexing and | |
539 | * retrieval of views. | |
540 | * </p> | |
541 | * | |
542 | * @return String view type name for the view | |
543 | */ | |
544 | public String getViewTypeName() { | |
545 | 0 | return this.viewTypeName; |
546 | } | |
547 | ||
548 | /** | |
549 | * Setter for the view's type name | |
550 | * | |
551 | * @param viewTypeName | |
552 | */ | |
553 | public void setViewTypeName(String viewTypeName) { | |
554 | 0 | this.viewTypeName = viewTypeName; |
555 | 0 | } |
556 | ||
557 | /** | |
558 | * Class name of the <code>ViewHelperService</code> that handles the various | |
559 | * phases of the Views lifecycle | |
560 | * | |
561 | * @return Class for the spring bean | |
562 | * @see org.kuali.rice.krad.uif.service.ViewHelperService | |
563 | */ | |
564 | public Class<? extends ViewHelperService> getViewHelperServiceClassName() { | |
565 | 0 | return this.viewHelperServiceClassName; |
566 | } | |
567 | ||
568 | /** | |
569 | * Setter for the <code>ViewHelperService</code> class name | |
570 | * | |
571 | * @param viewLifecycleService | |
572 | */ | |
573 | public void setViewHelperServiceClassName(Class<? extends ViewHelperService> viewHelperServiceClassName) { | |
574 | 0 | this.viewHelperServiceClassName = viewHelperServiceClassName; |
575 | 0 | } |
576 | ||
577 | /** | |
578 | * Creates the <code>ViewHelperService</code> associated with the View | |
579 | * | |
580 | * @return ViewHelperService instance | |
581 | */ | |
582 | public ViewHelperService getViewHelperService() { | |
583 | 0 | if (this.viewHelperService == null) { |
584 | 0 | viewHelperService = ObjectUtils.newInstance(viewHelperServiceClassName); |
585 | } | |
586 | ||
587 | 0 | return viewHelperService; |
588 | } | |
589 | ||
590 | /** | |
591 | * Invoked to produce a ViewIndex of the current view's components | |
592 | */ | |
593 | public void index() { | |
594 | 0 | ViewIndex viewIndex = new ViewIndex(this); |
595 | 0 | this.viewIndex = viewIndex; |
596 | 0 | } |
597 | ||
598 | /** | |
599 | * Holds field indexes of the <code>View</code> instance for retrieval | |
600 | * | |
601 | * @return ViewIndex instance | |
602 | */ | |
603 | public ViewIndex getViewIndex() { | |
604 | 0 | return this.viewIndex; |
605 | } | |
606 | ||
607 | /** | |
608 | * Map of parameters from the request that set view options, used to rebuild | |
609 | * the view on each post | |
610 | * <p> | |
611 | * Views can be configured by parameters. These might impact which parts of | |
612 | * the view are rendered or how the view behaves. Generally these would get | |
613 | * passed in when a new view is requested (by request parameters). These | |
614 | * will be used to initially populate the view properties. In addition, on a | |
615 | * post the view will be rebuilt and properties reset again by the allow | |
616 | * request parameters. | |
617 | * </p> | |
618 | * <p> | |
619 | * Example parameter would be for MaintenaceView whether a New, Edit, or | |
620 | * Copy was requested (maintenance mode) | |
621 | * </p> | |
622 | * | |
623 | * @return | |
624 | */ | |
625 | public Map<String, String> getViewRequestParameters() { | |
626 | 0 | return this.viewRequestParameters; |
627 | } | |
628 | ||
629 | /** | |
630 | * Setter for the view's request parameters map | |
631 | * | |
632 | * @param viewRequestParameters | |
633 | */ | |
634 | public void setViewRequestParameters(Map<String, String> viewRequestParameters) { | |
635 | 0 | this.viewRequestParameters = viewRequestParameters; |
636 | 0 | } |
637 | ||
638 | /** | |
639 | * PresentationController class that should be used for the | |
640 | * <code>View</code> instance | |
641 | * <p> | |
642 | * The presentation controller is consulted to determine component (group, | |
643 | * field) state such as required, read-only, and hidden. The presentation | |
644 | * controller does not take into account user permissions. The presentation | |
645 | * controller can also output action flags and edit modes that will be set | |
646 | * onto the view instance and can be referred to by conditional expressions | |
647 | * </p> | |
648 | * | |
649 | * @return Class<? extends PresentationController> | |
650 | * @see org.kuali.rice.krad.uif.container.View.getActionFlags() | |
651 | * @see org.kuali.rice.krad.uif.container.View.getEditModes() | |
652 | */ | |
653 | public Class<? extends PresentationController> getPresentationControllerClass() { | |
654 | 0 | return this.presentationControllerClass; |
655 | } | |
656 | ||
657 | /** | |
658 | * Setter for the view's presentation controller | |
659 | * | |
660 | * @param presentationControllerClass | |
661 | */ | |
662 | public void setPresentationControllerClass(Class<? extends PresentationController> presentationControllerClass) { | |
663 | 0 | this.presentationControllerClass = presentationControllerClass; |
664 | 0 | } |
665 | ||
666 | /** | |
667 | * Authorizer class that should be used for the <code>View</code> instance | |
668 | * <p> | |
669 | * The authorizer class is consulted to determine component (group, field) | |
670 | * state such as required, read-only, and hidden based on the users | |
671 | * permissions. It typically communicates with the Kuali Identity Management | |
672 | * system to determine roles and permissions. It is used with the | |
673 | * presentation controller and dictionary conditional logic to determine the | |
674 | * final component state. The authorizer can also output action flags and | |
675 | * edit modes that will be set onto the view instance and can be referred to | |
676 | * by conditional expressions | |
677 | * </p> | |
678 | * | |
679 | * @return Class<? extends Authorizer> | |
680 | * @see org.kuali.rice.krad.uif.container.View.getActionFlags() | |
681 | * @see org.kuali.rice.krad.uif.container.View.getEditModes() | |
682 | */ | |
683 | public Class<? extends Authorizer> getAuthorizerClass() { | |
684 | 0 | return this.authorizerClass; |
685 | } | |
686 | ||
687 | /** | |
688 | * Setter for the view's authorizer | |
689 | * | |
690 | * @param authorizerClass | |
691 | */ | |
692 | public void setAuthorizerClass(Class<? extends Authorizer> authorizerClass) { | |
693 | 0 | this.authorizerClass = authorizerClass; |
694 | 0 | } |
695 | ||
696 | /** | |
697 | * Map of strings that flag what actions can be taken in the UI | |
698 | * <p> | |
699 | * These can be used in conditional expressions in the dictionary or by | |
700 | * other UI logic | |
701 | * </p> | |
702 | * | |
703 | * @return BooleanMap action flags | |
704 | */ | |
705 | public BooleanMap getActionFlags() { | |
706 | 0 | return this.actionFlags; |
707 | } | |
708 | ||
709 | /** | |
710 | * Setter for the action flags Map | |
711 | * | |
712 | * @param actionFlags | |
713 | */ | |
714 | public void setActionFlags(BooleanMap actionFlags) { | |
715 | 0 | this.actionFlags = actionFlags; |
716 | 0 | } |
717 | ||
718 | /** | |
719 | * Map of edit modes that enabled for the view | |
720 | * <p> | |
721 | * These can be used in conditional expressions in the dictionary or by | |
722 | * other UI logic | |
723 | * </p> | |
724 | * | |
725 | * @return BooleanMap edit modes | |
726 | */ | |
727 | public BooleanMap getEditModes() { | |
728 | 0 | return this.editModes; |
729 | } | |
730 | ||
731 | /** | |
732 | * Setter for the edit modes Map | |
733 | * | |
734 | * @param editModes | |
735 | */ | |
736 | public void setEditModes(BooleanMap editModes) { | |
737 | 0 | this.editModes = editModes; |
738 | 0 | } |
739 | ||
740 | /** | |
741 | * Map that contains expressions to evaluate and make available as variables | |
742 | * for conditional expressions within the view | |
743 | * <p> | |
744 | * Each Map entry contains one expression variables, where the map key gives | |
745 | * the name for the variable, and the map value gives the variable | |
746 | * expression. The variables expressions will be evaluated before | |
747 | * conditional logic is run and made available as variables for other | |
748 | * conditional expressions. Variable expressions can be based on the model | |
749 | * and any object contained in the view's context | |
750 | * </p> | |
751 | * | |
752 | * @return Map<String, String> variable expressions | |
753 | */ | |
754 | public Map<String, String> getExpressionVariables() { | |
755 | 0 | return this.expressionVariables; |
756 | } | |
757 | ||
758 | /** | |
759 | * Setter for the view's map of variable expressions | |
760 | * | |
761 | * @param expressionVariables | |
762 | */ | |
763 | public void setExpressionVariables(Map<String, String> expressionVariables) { | |
764 | 0 | this.expressionVariables = expressionVariables; |
765 | 0 | } |
766 | ||
767 | /** | |
768 | * Indicates whether the <code>View</code> only has a single page | |
769 | * <code>Group</code> or contains multiple page <code>Group</code> | |
770 | * instances. In the case of a single page it is assumed the group's items | |
771 | * list contains the section groups for the page, and the page itself is | |
772 | * given by the page property ({@link #getPage()}. This is for convenience | |
773 | * of configuration and also can drive other configuration like styling. | |
774 | * | |
775 | * @return boolean true if the view only contains one page group, false if | |
776 | * it contains multple pages | |
777 | */ | |
778 | public boolean isSinglePageView() { | |
779 | 0 | return this.singlePageView; |
780 | } | |
781 | ||
782 | /** | |
783 | * Setter for the single page indicator | |
784 | * | |
785 | * @param singlePageView | |
786 | */ | |
787 | public void setSinglePageView(boolean singlePageView) { | |
788 | 0 | this.singlePageView = singlePageView; |
789 | 0 | } |
790 | ||
791 | /** | |
792 | * For single paged views ({@link #isSinglePageView()}, gives the page | |
793 | * <code>Group</code> the view should render. The actual items for the page | |
794 | * is taken from the group's items list ({@link #getItems()}, and set onto | |
795 | * the give page group. This is for convenience of configuration. | |
796 | * | |
797 | * @return Group page group for single page views | |
798 | */ | |
799 | public PageGroup getPage() { | |
800 | 0 | return this.page; |
801 | } | |
802 | ||
803 | /** | |
804 | * Setter for the page group for single page views | |
805 | * | |
806 | * @param page | |
807 | */ | |
808 | public void setPage(PageGroup page) { | |
809 | 0 | this.page = page; |
810 | 0 | } |
811 | ||
812 | /** | |
813 | * @see org.kuali.rice.krad.uif.container.ContainerBase#getItems() | |
814 | */ | |
815 | @Override | |
816 | public List<? extends Group> getItems() { | |
817 | 0 | return this.items; |
818 | } | |
819 | ||
820 | /** | |
821 | * Setter for the view's <code>Group</code> instances | |
822 | * | |
823 | * @param items | |
824 | */ | |
825 | @Override | |
826 | public void setItems(List<? extends Component> items) { | |
827 | // TODO: fix this generic issue | |
828 | 0 | this.items = (List<? extends Group>) items; |
829 | 0 | } |
830 | ||
831 | /** | |
832 | * Provides configuration for displaying a link to the view from an | |
833 | * application menu | |
834 | * | |
835 | * @return LinkField view link field | |
836 | */ | |
837 | public LinkField getViewMenuLink() { | |
838 | 0 | return this.viewMenuLink; |
839 | } | |
840 | ||
841 | /** | |
842 | * Setter for the views link field | |
843 | * | |
844 | * @param viewMenuLink | |
845 | */ | |
846 | public void setViewMenuLink(LinkField viewMenuLink) { | |
847 | 0 | this.viewMenuLink = viewMenuLink; |
848 | 0 | } |
849 | ||
850 | /** | |
851 | * Provides a grouping string for the view to group its menu link (within a | |
852 | * portal for instance) | |
853 | * | |
854 | * @return String menu grouping | |
855 | */ | |
856 | public String getViewMenuGrouping() { | |
857 | 0 | return this.viewMenuGrouping; |
858 | } | |
859 | ||
860 | /** | |
861 | * Setter for the views menu grouping | |
862 | * | |
863 | * @param viewMenuGrouping | |
864 | */ | |
865 | public void setViewMenuGrouping(String viewMenuGrouping) { | |
866 | 0 | this.viewMenuGrouping = viewMenuGrouping; |
867 | 0 | } |
868 | ||
869 | /** | |
870 | * Indicates what lifecycle phase the View instance is in | |
871 | * <p> | |
872 | * The view lifecycle begins with the CREATED status. In this status a new | |
873 | * instance of the view has been retrieved from the dictionary, but no | |
874 | * further processing has been done. After the initialize phase has been run | |
875 | * the status changes to INITIALIZED. After the model has been applied and | |
876 | * the view is ready for render the status changes to FINAL | |
877 | * </p> | |
878 | * | |
879 | * @return String view status | |
880 | * @see org.kuali.rice.krad.uif.UifConstants.ViewStatus | |
881 | */ | |
882 | public String getViewStatus() { | |
883 | 0 | return this.viewStatus; |
884 | } | |
885 | ||
886 | /** | |
887 | * Setter for the view status | |
888 | * | |
889 | * @param viewStatus | |
890 | */ | |
891 | public void setViewStatus(String viewStatus) { | |
892 | 0 | this.viewStatus = viewStatus; |
893 | 0 | } |
894 | ||
895 | /** | |
896 | * Indicates whether the view has been initialized | |
897 | * | |
898 | * @return boolean true if the view has been initialized, false if not | |
899 | */ | |
900 | public boolean isInitialized() { | |
901 | 0 | return StringUtils.equals(viewStatus, ViewStatus.INITIALIZED) || |
902 | StringUtils.equals(viewStatus, ViewStatus.FINAL); | |
903 | } | |
904 | ||
905 | /** | |
906 | * Indicates whether the view has been updated from the model and final | |
907 | * updates made | |
908 | * | |
909 | * @return boolean true if the view has been updated, false if not | |
910 | */ | |
911 | public boolean isFinal() { | |
912 | 0 | return StringUtils.equals(viewStatus, ViewStatus.FINAL); |
913 | } | |
914 | ||
915 | /** | |
916 | * onSubmit script configured on the <code>View</code> gets placed on the | |
917 | * form element | |
918 | * | |
919 | * @see org.kuali.rice.krad.uif.core.ComponentBase#getSupportsOnSubmit() | |
920 | */ | |
921 | @Override | |
922 | public boolean getSupportsOnSubmit() { | |
923 | 0 | return true; |
924 | } | |
925 | ||
926 | /** | |
927 | * onLoad script configured on the <code>View</code> gets placed in a load | |
928 | * call | |
929 | * | |
930 | * @see org.kuali.rice.krad.uif.core.ComponentBase#getSupportsOnLoad() | |
931 | */ | |
932 | @Override | |
933 | public boolean getSupportsOnLoad() { | |
934 | 0 | return true; |
935 | } | |
936 | ||
937 | /** | |
938 | * onDocumentReady script configured on the <code>View</code> gets placed in | |
939 | * a document ready jQuery block | |
940 | * | |
941 | * @see org.kuali.rice.krad.uif.core.ComponentBase#getSupportsOnLoad() | |
942 | */ | |
943 | @Override | |
944 | public boolean getSupportsOnDocumentReady() { | |
945 | 0 | return true; |
946 | } | |
947 | ||
948 | /** | |
949 | * Breadcrumb widget used for displaying homeward path and history | |
950 | * | |
951 | * @return the breadcrumbs | |
952 | */ | |
953 | public BreadCrumbs getBreadcrumbs() { | |
954 | 0 | return this.breadcrumbs; |
955 | } | |
956 | ||
957 | /** | |
958 | * @param breadcrumbs the breadcrumbs to set | |
959 | */ | |
960 | public void setBreadcrumbs(BreadCrumbs breadcrumbs) { | |
961 | 0 | this.breadcrumbs = breadcrumbs; |
962 | 0 | } |
963 | ||
964 | /** | |
965 | * Growls widget which sets up global settings for the growls used in this | |
966 | * view and its pages | |
967 | * | |
968 | * @return the growlsWidget | |
969 | */ | |
970 | public GrowlsWidget getGrowlsWidget() { | |
971 | 0 | return this.growlsWidget; |
972 | } | |
973 | ||
974 | /** | |
975 | * @param growlsWidget the growlsWidget to set | |
976 | */ | |
977 | public void setGrowlsWidget(GrowlsWidget growlsWidget) { | |
978 | 0 | this.growlsWidget = growlsWidget; |
979 | 0 | } |
980 | ||
981 | /** | |
982 | * Growls use the messages contained in the message map. If enabled, info | |
983 | * messages in their entirety will be displayed in growls, for warning and | |
984 | * error messages a growl message will notify the user that these messages | |
985 | * exist on the page. If this setting is disabled, it is recommended that | |
986 | * infoMessage display be enabled for the page ErrorsField bean in order to | |
987 | * display relevant information to the user. Note: the growl scripts are | |
988 | * built out in the PageGroup class. | |
989 | * | |
990 | * @return the growlMessagingEnabled | |
991 | */ | |
992 | public boolean isGrowlMessagingEnabled() { | |
993 | 0 | return this.growlMessagingEnabled; |
994 | } | |
995 | ||
996 | /** | |
997 | * @param growlMessagingEnabled the growlMessagingEnabled to set | |
998 | */ | |
999 | public void setGrowlMessagingEnabled(boolean growlMessagingEnabled) { | |
1000 | 0 | this.growlMessagingEnabled = growlMessagingEnabled; |
1001 | 0 | } |
1002 | ||
1003 | /** | |
1004 | * Indicates whether the form should be validated for dirtyness. | |
1005 | * | |
1006 | * <p>For FormView, it's necessary to validate when the user tries to navigate out of the form. If set, all the AttributeFields | |
1007 | * will be validated on refresh, navigate, cancel or close Action or on form unload and if dirty, displays a message and user | |
1008 | * can decide whether to continue with the action or stay on the form. For lookup and inquiry, it's not needed to validate. | |
1009 | * </p> | |
1010 | * | |
1011 | * @return true if dirty validation is set | |
1012 | */ | |
1013 | public boolean isValidateDirty() { | |
1014 | 0 | return this.validateDirty; |
1015 | } | |
1016 | ||
1017 | /** | |
1018 | * Setter for dirty validation. | |
1019 | */ | |
1020 | public void setValidateDirty(boolean validateDirty) { | |
1021 | 0 | this.validateDirty = validateDirty; |
1022 | 0 | } |
1023 | ||
1024 | /** | |
1025 | * Indicates whether the Name of the Code should be displayed when a property is of type <code>KualiCode</code> | |
1026 | * | |
1027 | * @param translateCodes - indicates whether <code>KualiCode</code>'s name should be included | |
1028 | */ | |
1029 | public void setTranslateCodes(boolean translateCodes) { | |
1030 | 0 | this.translateCodes = translateCodes; |
1031 | 0 | } |
1032 | ||
1033 | /** | |
1034 | * Returns whether the current view supports displaying <code>KualiCode</code>'s name as additional display value | |
1035 | * | |
1036 | * @return true if the current view supports | |
1037 | */ | |
1038 | public boolean isTranslateCodes() { | |
1039 | 0 | return translateCodes; |
1040 | } | |
1041 | ||
1042 | /** | |
1043 | * @return the viewLabelFieldPropertyName | |
1044 | */ | |
1045 | public String getViewLabelFieldPropertyName() { | |
1046 | 0 | return this.viewLabelFieldPropertyName; |
1047 | } | |
1048 | ||
1049 | /** | |
1050 | * Sets the property name to be used to determine what will be used in the | |
1051 | * breadcrumb title of this view | |
1052 | * The title can be determined from a | |
1053 | * combination of this and viewLabelFieldbindingInfo: If only | |
1054 | * viewLabelFieldPropertyName is set, the title we be determined against the | |
1055 | * defaultBindingObjectPath. If only viewLabelFieldbindingInfo is set it | |
1056 | * must provide information about what object(bindToForm or explicit) and | |
1057 | * path to use. If both viewLabelFieldbindingInfo and | |
1058 | * viewLabelFieldPropertyName are set, the bindingInfo will be used with a | |
1059 | * the viewLabelFieldPropertyName as its bindingPath. If neither are set, | |
1060 | * the default title attribute from the dataObject's metadata (determined by the | |
1061 | * defaultBindingObjectPath's object) will be used. | |
1062 | * | |
1063 | * @param viewLabelFieldPropertyName the viewLabelFieldPropertyName to set | |
1064 | */ | |
1065 | public void setViewLabelFieldPropertyName(String viewLabelFieldPropertyName) { | |
1066 | 0 | this.viewLabelFieldPropertyName = viewLabelFieldPropertyName; |
1067 | 0 | } |
1068 | ||
1069 | /** | |
1070 | * @return the viewLabelFieldBindingInfo | |
1071 | */ | |
1072 | public BindingInfo getViewLabelFieldBindingInfo() { | |
1073 | 0 | return this.viewLabelFieldBindingInfo; |
1074 | } | |
1075 | ||
1076 | /** | |
1077 | * The binding info settings to use when selecting a field to use in the | |
1078 | * breadcrumb title for this view. | |
1079 | * The title can be determined from a | |
1080 | * combination of this and viewLabelFieldPropertyName: If only | |
1081 | * viewLabelFieldPropertyName is set, the title we be determined against the | |
1082 | * defaultBindingObjectPath. If only viewLabelFieldbindingInfo is set it | |
1083 | * must provide information about what object(bindToForm or explicit) and | |
1084 | * path to use. If both viewLabelFieldbindingInfo and | |
1085 | * viewLabelFieldPropertyName are set, the bindingInfo will be used with a | |
1086 | * the viewLabelFieldPropertyName as its bindingPath. If neither are set, | |
1087 | * the default title attribute from the dataObject's metadata (determined by the | |
1088 | * defaultBindingObjectPath's object) will be used. | |
1089 | * | |
1090 | * @param viewLabelFieldBindingInfo the viewLabelFieldBindingInfo to set | |
1091 | */ | |
1092 | public void setViewLabelFieldBindingInfo(BindingInfo viewLabelFieldBindingInfo) { | |
1093 | 0 | this.viewLabelFieldBindingInfo = viewLabelFieldBindingInfo; |
1094 | 0 | } |
1095 | ||
1096 | /** | |
1097 | * @return the appendOption | |
1098 | */ | |
1099 | public String getAppendOption() { | |
1100 | 0 | return this.appendOption; |
1101 | } | |
1102 | ||
1103 | /** | |
1104 | * The option to use when appending the view label on the breadcrumb title. | |
1105 | * Available options: 'dash', 'parenthesis', and 'replace'(don't append - | |
1106 | * simply replace the title). MUST be set for the viewLabelField to be used | |
1107 | * in the breadcrumb, if not set no appendage will be added. | |
1108 | * | |
1109 | * @param appendOption the appendOption to set | |
1110 | * @see View#setViewLabelFieldPropertyName(String) | |
1111 | * @see View#setViewLabelFieldBindingInfo(BindingInfo) | |
1112 | */ | |
1113 | public void setAppendOption(String appendOption) { | |
1114 | 0 | this.appendOption = appendOption; |
1115 | 0 | } |
1116 | } |