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