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.view; 17 18 import org.kuali.rice.krad.uif.UifConstants.ViewType; 19 20 import java.io.Serializable; 21 import java.util.List; 22 import java.util.Map; 23 import java.util.Set; 24 25 /** 26 * Interface that must be implemented for clases the provide the backing data (model) for a {@link View} 27 * 28 * <p> 29 * Since the View relies on helper properties from the model it is necessary the backing object implement this 30 * interface. Note model objects can extend {@link org.kuali.rice.krad.web.form.UifFormBase} which implements 31 * this interface 32 * </p> 33 * 34 * @author Kuali Rice Team (rice.collab@kuali.org) 35 */ 36 public interface ViewModel extends Serializable { 37 38 /** 39 * Unique Id for the <code>View</code> instance. This is specified for a 40 * view in its definition by setting the 'id' property. 41 * 42 * @return String view id 43 */ 44 public String getViewId(); 45 46 /** 47 * Setter for the unique view id 48 * 49 * @param viewId 50 */ 51 public void setViewId(String viewId); 52 53 /** 54 * Name for the <code>View</code> instance. This is specified for a view in 55 * its definition by setting the 'id' property. The name is not necessary 56 * unique and cannot be used by itself to retrieve a view. Typically it is 57 * used with other parameters to identify a view with a certain type (view 58 * type) 59 * 60 * @return String view name 61 */ 62 public String getViewName(); 63 64 /** 65 * Setter for the view name 66 * 67 * @param viewName 68 */ 69 public void setViewName(String viewName); 70 71 /** 72 * Name for the type of view being requested. This can be used to find 73 * <code>View</code> instances by request parameters (not necessary the 74 * unique id) 75 * 76 * @return String view type name 77 */ 78 public ViewType getViewTypeName(); 79 80 /** 81 * Setter for the view type name 82 * 83 * @param viewTypeName 84 */ 85 public void setViewTypeName(ViewType viewTypeName); 86 87 /** 88 * View instance associated with the model. Used to render the user interface 89 * 90 * @return View 91 */ 92 public View getView(); 93 94 /** 95 * Setter for the view instance 96 * 97 * @param view 98 */ 99 public void setView(View view); 100 101 /** 102 * View instance for the page that made a request. Since a new view instance 103 * gets initialized for each request before the controller logic is invoked, 104 * any state about the previous view is lost. This could be needed to read 105 * metadata from the view for such things as collection processing. When 106 * this is necessary the previous view instance can be retrieved 107 * 108 * @return View instance 109 */ 110 public View getPostedView(); 111 112 /** 113 * Setter for the previous view instance 114 * 115 * @param previousView 116 */ 117 public void setPostedView(View previousView); 118 119 /** 120 * Id for the current page being displayed within the view 121 * 122 * @return String page id 123 */ 124 public String getPageId(); 125 126 /** 127 * Setter for the current page id 128 * 129 * @param pageId 130 */ 131 public void setPageId(String pageId); 132 133 /** 134 * URL the form generated for the view should post to 135 * 136 * @return String form post URL 137 */ 138 public String getFormPostUrl(); 139 140 /** 141 * Setter for the form post URL 142 * 143 * @param formPostUrl 144 */ 145 public void setFormPostUrl(String formPostUrl); 146 147 /** 148 * Map of parameters that was used to configured the <code>View</code>. 149 * Maintained on the form to rebuild the view on posts and session timeout 150 * 151 * @return Map<String, String> view parameters 152 * @see org.kuali.rice.krad.uif.view.View.getViewRequestParameters() 153 */ 154 public Map<String, String> getViewRequestParameters(); 155 156 /** 157 * Setter for the view's request parameter map 158 * 159 * @param viewRequestParameters 160 */ 161 public void setViewRequestParameters(Map<String, String> viewRequestParameters); 162 163 /** 164 * List of fields that should be read only on the view 165 * 166 * <p> 167 * If the view being rendered supports request setting of read-only fields, the readOnlyFields request parameter 168 * can be sent to mark fields as read only that might not have been otherwise 169 * </p> 170 * 171 * <p> 172 * Note the paths specified should be the simple property names (not the full binding path). Therefore if the 173 * property name appears multiple times in the view, all instances will be set as read only 174 * </p> 175 * 176 * @return List<String> read only property names 177 * @see View#isSupportsReadOnlyFieldsOverride() 178 */ 179 public List<String> getReadOnlyFieldsList(); 180 181 /** 182 * Setter for the list of read only fields 183 * 184 * @param readOnlyFieldsList 185 */ 186 public void setReadOnlyFieldsList(List<String> readOnlyFieldsList); 187 188 /** 189 * Holds instances for collection add lines. The key of the Map gives the 190 * collection name the line instance applies to, the Map value is an 191 * instance of the collection object class that holds the new line data 192 * 193 * @return Map<String, Object> new collection lines 194 */ 195 public Map<String, Object> getNewCollectionLines(); 196 197 /** 198 * Setter for the new collection lines Map 199 * 200 * @param newCollectionLines 201 */ 202 public void setNewCollectionLines(Map<String, Object> newCollectionLines); 203 204 /** 205 * Map of parameters sent for the invoked action 206 * 207 * <p> 208 * Many times besides just setting the method to call actions need to send 209 * additional parameters. For instance the method being called might do a 210 * redirect, in which case the action needs to send parameters for the 211 * redirect URL. An example of this is redirecting to a <code>Lookup</code> 212 * view. In some cases the parameters that need to be sent conflict with 213 * properties already on the form, and putting all the action parameters as 214 * form properties would grow massive (in addition to adds an additional 215 * step from the XML config). So this general map solves those issues. 216 * </p> 217 * 218 * @return Map<String, String> action parameters 219 */ 220 public Map<String, String> getActionParameters(); 221 222 /** 223 * Setter for the action parameters map 224 * 225 * @param actionParameters 226 */ 227 public void setActionParameters(Map<String, String> actionParameters); 228 229 /** 230 * Map that is populated from the component state maintained on the client 231 * 232 * <p> 233 * Used when a request is made that refreshes part of the view. The current state for components (which 234 * have state that can be changed on the client), is populated into this map which is then used by the 235 * <code>ViewHelperService</code> to update the components so that the state is maintained when they render. 236 * </p> 237 * 238 * @return Map<String, Object> map where key is name of property or component id, and value is the property 239 * value or another map of component key/value pairs 240 */ 241 public Map<String, Object> getClientStateForSyncing(); 242 243 /** 244 * Holds Set of String identifiers for lines that were selected in a collection 245 * 246 * <p> 247 * When the select field is enabled for a <code>CollectionGroup</code>, the framework will be 248 * default bind the selected identifier strings to this property. The key of the map uniquely identifies the 249 * collection by the full binding path to the collection, and the value is a set of Strings for the checked 250 * lines. 251 * </p> 252 * 253 * @return Map<String, Set<String>> map of collections and their selected lines 254 * @see org.kuali.rice.krad.service.DataObjectMetaDataService#getDataObjectIdentifierString(java.lang.Object) 255 */ 256 public Map<String, Set<String>> getSelectedCollectionLines(); 257 258 /** 259 * Setter for the map that holds selected collection lines 260 * 261 * @param selectedCollectionLines 262 */ 263 public void setSelectedCollectionLines(Map<String, Set<String>> selectedCollectionLines); 264 265 /** 266 * Indicates whether the form has had default values from the configured 267 * <code>View</code> applied. This happens only once for each form instance 268 * 269 * @return boolean true if default values have been applied, false if not 270 */ 271 public boolean isDefaultsApplied(); 272 273 /** 274 * Setter for the defaults applied indicator 275 * 276 * @param defaultsApplied 277 */ 278 public void setDefaultsApplied(boolean defaultsApplied); 279 280 }