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