View Javadoc

1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.service;
17  
18  import org.kuali.rice.krad.uif.UifConstants;
19  import org.kuali.rice.krad.uif.view.View;
20  import org.kuali.rice.krad.uif.UifConstants.ViewType;
21  
22  import java.util.Map;
23  
24  /**
25   * Provides service methods for retrieving and updating <code>View</code> instances. The UIF
26   * interacts with this service from the client layer to pull information from the View dictionary
27   * and manage the View instance through its lifecycle
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public interface ViewService {
32  
33      /**
34       * Returns the <code>View</code> entry identified by the given id
35       *
36       * <p>
37       * The id matches the id configured for the View through the dictionary. A new view instance
38       * is returned that is in the created state
39       * </p>
40       *
41       * @param viewId - unique id for view configured on its definition
42       * @return View instance associated with the id or Null if id is not found
43       */
44      public View getViewById(String viewId);
45  
46      /**
47       * Retrieves the <code>View</code> instance that is of the given view type and matches the
48       * given parameters (that are applicable for that type). If more than one views exists for the
49       * type and parameters, the view type may choose a default or throw an exception
50       *
51       * <p>
52       * If a view if found for the type parameters, a new instance is returned that is in the
53       * created state
54       * </p>
55       *
56       * @param viewType - name that identifies the view type
57       * @param parameters - Map of parameter key/value pairs that are used to select the
58       * view, the parameters allowed depend on the view type
59       * @return View instance or Null if a matching view was not found
60       */
61      public View getViewByType(ViewType viewType, Map<String, String> parameters);
62  
63      /**
64       * Retrieves the view id for the view associated with the given view type and view type parameters
65       *
66       * @param viewType name that identifies the view type
67       * @param parameters Map of parameter key/value pairs that are used to select the
68       * view, the parameters allowed depend on the view type
69       * @return id for the view or null if a matching view was not found
70       */
71      public String getViewIdForViewType(ViewType viewType, Map<String, String> parameters);
72  
73      /**
74       * Executes the view lifecycle on the given <code>View</code> instance which will
75       * prepare it for rendering
76       *
77       * <p>
78       * Any configuration sent through the options Map is used to initialize the
79       * View. This map contains present options the view is aware of and will
80       * typically come from request parameters. e.g. For maintenance Views there
81       * is the maintenance type option (new, edit, copy)
82       * </p>
83       *
84       * <p>
85       * After view retrieval, applies updates to the view based on the model data which
86       * Performs dynamic generation of fields (such as collection rows),
87       * conditional logic, and state updating (conditional hidden, read-only,
88       * required).
89       * </p>
90       *
91       * @param view - view instance that should be built
92       * @param model - object instance containing the view data
93       * @param parameters - Map of key values pairs that provide configuration for the
94       * <code>View</code>, this is generally comes from the request
95       * and can be the request parameter Map itself. Any parameters
96       * not valid for the View will be filtered out
97       */
98      public void buildView(View view, Object model, Map<String, String> parameters);
99  
100     // TODO: remove once can get beans by type
101     public ViewTypeService getViewTypeService(UifConstants.ViewType viewType);
102 
103 }