View Javadoc

1   /**
2    * Copyright 2005-2013 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       * Executes the view lifecycle on the given <code>View</code> instance which will
65       * prepare it for rendering
66       *
67       * <p>
68       * Any configuration sent through the options Map is used to initialize the
69       * View. This map contains present options the view is aware of and will
70       * typically come from request parameters. e.g. For maintenance Views there
71       * is the maintenance type option (new, edit, copy)
72       * </p>
73       *
74       * <p>
75       * After view retrieval, applies updates to the view based on the model data which
76       * Performs dynamic generation of fields (such as collection rows),
77       * conditional logic, and state updating (conditional hidden, read-only,
78       * required).
79       * </p>
80       *
81       * @param view - view instance that should be built
82       * @param model - object instance containing the view data
83       * @param parameters - Map of key values pairs that provide configuration for the
84       * <code>View</code>, this is generally comes from the request
85       * and can be the request parameter Map itself. Any parameters
86       * not valid for the View will be filtered out
87       */
88      public void buildView(View view, Object model, Map<String, String> parameters);
89  
90      // TODO: remove once can get beans by type
91      public ViewTypeService getViewTypeService(UifConstants.ViewType viewType);
92  
93  }