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