001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.uif.view;
017    
018    import org.kuali.rice.krad.uif.UifConstants.ViewType;
019    
020    import java.io.Serializable;
021    import java.util.List;
022    import java.util.Map;
023    import java.util.Set;
024    
025    /**
026     * Interface that must be implemented for clases the provide the backing data (model) for a {@link View}
027     *
028     * <p>
029     * Since the View relies on helper properties from the model it is necessary the backing object implement this
030     * interface. Note model objects can extend {@link org.kuali.rice.krad.web.form.UifFormBase} which implements
031     * this interface
032     * </p>
033     *
034     * @author Kuali Rice Team (rice.collab@kuali.org)
035     */
036    public interface ViewModel extends Serializable {
037    
038        /**
039         * Unique Id for the <code>View</code> instance. This is specified for a
040         * view in its definition by setting the 'id' property.
041         *
042         * @return String view id
043         */
044        public String getViewId();
045    
046        /**
047         * Setter for the unique view id
048         *
049         * @param viewId
050         */
051        public void setViewId(String viewId);
052    
053        /**
054         * Name for the <code>View</code> instance. This is specified for a view in
055         * its definition by setting the 'id' property. The name is not necessary
056         * unique and cannot be used by itself to retrieve a view. Typically it is
057         * used with other parameters to identify a view with a certain type (view
058         * type)
059         *
060         * @return String view name
061         */
062        public String getViewName();
063    
064        /**
065         * Setter for the view name
066         *
067         * @param viewName
068         */
069        public void setViewName(String viewName);
070    
071        /**
072         * Name for the type of view being requested. This can be used to find
073         * <code>View</code> instances by request parameters (not necessary the
074         * unique id)
075         *
076         * @return String view type name
077         */
078        public ViewType getViewTypeName();
079    
080        /**
081         * Setter for the view type name
082         *
083         * @param viewTypeName
084         */
085        public void setViewTypeName(ViewType viewTypeName);
086    
087        /**
088         * View instance associated with the model. Used to render the user interface
089         *
090         * @return View
091         */
092        public View getView();
093    
094        /**
095         * Setter for the view instance
096         *
097         * @param view
098         */
099        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    }