| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ViewHelperService |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 1.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/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, | |
| 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.kns.uif.service; | |
| 17 | ||
| 18 | import java.util.Map; | |
| 19 | ||
| 20 | import org.kuali.rice.kns.uif.container.View; | |
| 21 | import org.kuali.rice.kns.uif.core.Component; | |
| 22 | import org.kuali.rice.kns.uif.widget.Inquiry; | |
| 23 | ||
| 24 | /** | |
| 25 | * Provides methods for implementing the various phases of a <code>View</code> | |
| 26 | * | |
| 27 | * <ul> | |
| 28 | * <li>Initialize Phase: Invoked when the view is first requested to setup | |
| 29 | * necessary state</li> | |
| 30 | * </ul> | |
| 31 | * | |
| 32 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 33 | */ | |
| 34 | public interface ViewHelperService { | |
| 35 | ||
| 36 | /** | |
| 37 | * Populates the <code>View</code> properties from the given request | |
| 38 | * parameters | |
| 39 | * | |
| 40 | * <p> | |
| 41 | * The <code>View</code> instance is inspected for fields that have the | |
| 42 | * <code>RequestParameter</code> annotation and if corresponding parameters | |
| 43 | * are found in the request parameter map, the request value is used to set | |
| 44 | * the view property. The Map of parameter name/values that match are placed | |
| 45 | * in the view so they can be later retrieved to rebuild the view. Custom | |
| 46 | * <code>ViewServiceHelper</code> implementations can add additional | |
| 47 | * parameter key/value pairs to the returned map if necessary. | |
| 48 | * </p> | |
| 49 | * | |
| 50 | * @see org.kuali.rice.kns.uif.core.RequestParameter | |
| 51 | */ | |
| 52 | public void populateViewFromRequestParameters(View view, Map<String, String> parameters); | |
| 53 | ||
| 54 | /** | |
| 55 | * Performs the Initialization phase for the <code>View</code>. During this | |
| 56 | * phase each component of the tree is invoked to setup state based on the | |
| 57 | * configuration and request options. | |
| 58 | * | |
| 59 | * <p> | |
| 60 | * The initialize phase is only called once per <code>View</code> lifecycle | |
| 61 | * (when first requested) | |
| 62 | * </p> | |
| 63 | * | |
| 64 | * <p> | |
| 65 | * Note the <code>View</code> instance also contains the context Map that | |
| 66 | * was created based on the parameters sent to the view service | |
| 67 | * </p> | |
| 68 | * | |
| 69 | * @param view | |
| 70 | * - View instance that should be initialized | |
| 71 | */ | |
| 72 | public void performInitialization(View view); | |
| 73 | ||
| 74 | /** | |
| 75 | * Performs the Initialization phase for the given <code>Component</code> | |
| 76 | * | |
| 77 | * <p> | |
| 78 | * Can be called for component instances constructed via code or prototypes | |
| 79 | * to initialize the constructed component | |
| 80 | * </p> | |
| 81 | * | |
| 82 | * @param view | |
| 83 | * - view instance the component belongs to | |
| 84 | * @param component | |
| 85 | * - component instance that should be initialized | |
| 86 | */ | |
| 87 | public void performComponentInitialization(View view, Component component); | |
| 88 | ||
| 89 | /** | |
| 90 | * Executes the ApplyModel phase. During this phase each component of the | |
| 91 | * tree if invoked to setup any state based on the given model data | |
| 92 | * | |
| 93 | * <p> | |
| 94 | * Part of the view lifecycle that applies the model data to the view. | |
| 95 | * Should be called after the model has been populated before the view is | |
| 96 | * rendered. The main things that occur during this phase are: | |
| 97 | * <ul> | |
| 98 | * <li>Generation of dynamic fields (such as collection rows)</li> | |
| 99 | * <li>Execution of conditional logic (hidden, read-only, required settings | |
| 100 | * based on model values)</li> | |
| 101 | * </ul> | |
| 102 | * </p> | |
| 103 | * | |
| 104 | * <p> | |
| 105 | * The update phase can be called multiple times for the view's lifecycle | |
| 106 | * (typically only once per request) | |
| 107 | * </p> | |
| 108 | * | |
| 109 | * @param view | |
| 110 | * - View instance that the model should be applied to | |
| 111 | * @param model | |
| 112 | * - Top level object containing the data (could be the form or a | |
| 113 | * top level business object, dto) | |
| 114 | */ | |
| 115 | public void performApplyModel(View view, Object model); | |
| 116 | ||
| 117 | /** | |
| 118 | * The last phase before the view is rendered. Here final preparations can | |
| 119 | * be made based on the updated view state | |
| 120 | * | |
| 121 | * <p> | |
| 122 | * The finalize phase runs after the apply model phase and can be called | |
| 123 | * multiple times for the view's lifecylce (however typically only once per | |
| 124 | * request) | |
| 125 | * </p> | |
| 126 | * | |
| 127 | * | |
| 128 | * @param view | |
| 129 | * - view instance that should be finalized for rendering | |
| 130 | * @param model | |
| 131 | * - top level object containing the data | |
| 132 | */ | |
| 133 | public void performFinalize(View view, Object model); | |
| 134 | ||
| 135 | /** | |
| 136 | * Invoked when the add line action is chosen for a collection. The | |
| 137 | * collection path gives the full path to the collection that action was | |
| 138 | * selected for. Here validation can be performed on the line as well as | |
| 139 | * further processing on the line such as defaults. If the action is valid | |
| 140 | * the line should be added to the collection, otherwise errors should be | |
| 141 | * added to the global <code>MessageMap</code> | |
| 142 | * | |
| 143 | * @param view | |
| 144 | * - view instance that is being presented (the action was taken | |
| 145 | * on) | |
| 146 | * @param model | |
| 147 | * - Top level object containing the view data including the | |
| 148 | * collection and new line | |
| 149 | * @param collectionPath | |
| 150 | * - full path to the collection on the model | |
| 151 | */ | |
| 152 | public void processCollectionAddLine(View view, Object model, String collectionPath); | |
| 153 | ||
| 154 | /** | |
| 155 | * Invoked when the delete line action is chosen for a collection. The | |
| 156 | * collection path gives the full path to the collection that action was | |
| 157 | * selected for. Here validation can be performed to make sure the action is | |
| 158 | * allowed. If the action is valid the line should be deleted from the | |
| 159 | * collection, otherwise errors should be added to the global | |
| 160 | * <code>MessageMap</code> | |
| 161 | * | |
| 162 | * @param view | |
| 163 | * - view instance that is being presented (the action was taken | |
| 164 | * on) | |
| 165 | * @param model | |
| 166 | * - Top level object containing the view data including the | |
| 167 | * collection | |
| 168 | * @param collectionPath | |
| 169 | * - full path to the collection on the model | |
| 170 | * @param lineIndex | |
| 171 | * - index of the collection line that was selected for removal | |
| 172 | */ | |
| 173 | public void processCollectionDeleteLine(View view, Object model, String collectionPath, int lineIndex); | |
| 174 | ||
| 175 | /** | |
| 176 | * Invoked by the <code>Inquiry</code> widget to build the inquiry link | |
| 177 | * | |
| 178 | * <p> | |
| 179 | * Note this is used primarily for custom <code>Inquirable</code> | |
| 180 | * implementations to customize the inquiry class or parameters for an | |
| 181 | * inquiry. Instead of building the full inquiry link, implementations can | |
| 182 | * make a callback to | |
| 183 | * org.kuali.rice.kns.uif.widget.Inquiry.buildInquiryLink(Object, String, | |
| 184 | * Class<?>, Map<String, String>) given an inquiry class and parameters to | |
| 185 | * build the link field. | |
| 186 | * </p> | |
| 187 | * | |
| 188 | * @param dataObject | |
| 189 | * - parent object for the inquiry property | |
| 190 | * @param propertyName | |
| 191 | * - name of the property the inquiry is being built for | |
| 192 | * @param inquiry | |
| 193 | * - instance of the inquiry widget being built for the property | |
| 194 | */ | |
| 195 | public void buildInquiryLink(Object dataObject, String propertyName, Inquiry inquiry); | |
| 196 | ||
| 197 | } |