View Javadoc

1   /**
2    * Copyright 2005-2012 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 javax.servlet.http.HttpServletRequest;
21  import java.io.Serializable;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.Set;
25  
26  /**
27   * Interface that must be implemented for clases the provide the backing data (model) for a {@link View}
28   *
29   * <p>
30   * Since the View relies on helper properties from the model it is necessary the backing object implement this
31   * interface. Note model objects can extend {@link org.kuali.rice.krad.web.form.UifFormBase} which implements
32   * this interface
33   * </p>
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  public interface ViewModel extends Serializable {
38  
39      /**
40       * Called after Spring binds the request to the form and before the controller method is invoked
41       *
42       * @param request - request object containing the query parameters
43       */
44      public void postBind(HttpServletRequest request);
45  
46      /**
47       * Unique Id for the <code>View</code> instance. This is specified for a
48       * view in its definition by setting the 'id' property.
49       *
50       * @return String view id
51       */
52      public String getViewId();
53  
54      /**
55       * Setter for the unique view id
56       *
57       * @param viewId
58       */
59      public void setViewId(String viewId);
60  
61      /**
62       * Name for the <code>View</code> instance. This is specified for a view in
63       * its definition by setting the 'id' property. The name is not necessary
64       * unique and cannot be used by itself to retrieve a view. Typically it is
65       * used with other parameters to identify a view with a certain type (view
66       * type)
67       *
68       * @return String view name
69       */
70      public String getViewName();
71  
72      /**
73       * Setter for the view name
74       *
75       * @param viewName
76       */
77      public void setViewName(String viewName);
78  
79      /**
80       * Name for the type of view being requested. This can be used to find
81       * <code>View</code> instances by request parameters (not necessary the
82       * unique id)
83       *
84       * @return String view type name
85       */
86      public ViewType getViewTypeName();
87  
88      /**
89       * Setter for the view type name
90       *
91       * @param viewTypeName
92       */
93      public void setViewTypeName(ViewType viewTypeName);
94  
95      /**
96       * View instance associated with the model. Used to render the user interface
97       *
98       * @return View
99       */
100     public View getView();
101 
102     /**
103      * Setter for the view instance
104      *
105      * @param view
106      */
107     public void setView(View view);
108 
109     /**
110      * View instance for the page that made a request. Since a new view instance
111      * gets initialized for each request before the controller logic is invoked,
112      * any state about the previous view is lost. This could be needed to read
113      * metadata from the view for such things as collection processing. When
114      * this is necessary the previous view instance can be retrieved
115      *
116      * @return View instance
117      */
118     public View getPostedView();
119 
120     /**
121      * Setter for the previous view instance
122      *
123      * @param previousView
124      */
125     public void setPostedView(View previousView);
126 
127     /**
128      * Id for the current page being displayed within the view
129      *
130      * @return String page id
131      */
132     public String getPageId();
133 
134     /**
135      * Setter for the current page id
136      *
137      * @param pageId
138      */
139     public void setPageId(String pageId);
140 
141     /**
142      * URL the form generated for the view should post to
143      *
144      * @return String form post URL
145      */
146     public String getFormPostUrl();
147 
148     /**
149      * Setter for the form post URL
150      *
151      * @param formPostUrl
152      */
153     public void setFormPostUrl(String formPostUrl);
154 
155     /**
156      * Map of parameters that was used to configured the <code>View</code>.
157      * Maintained on the form to rebuild the view on posts and session timeout
158      *
159      * @return Map<String, String> view parameters
160      * @see org.kuali.rice.krad.uif.view.View.getViewRequestParameters()
161      */
162     public Map<String, String> getViewRequestParameters();
163 
164     /**
165      * Setter for the view's request parameter map
166      *
167      * @param viewRequestParameters
168      */
169     public void setViewRequestParameters(Map<String, String> viewRequestParameters);
170 
171     /**
172      * List of fields that should be read only on the view
173      *
174      * <p>
175      * If the view being rendered supports request setting of read-only fields, the readOnlyFields request parameter
176      * can be sent to mark fields as read only that might not have been otherwise
177      * </p>
178      *
179      * <p>
180      * Note the paths specified should be the simple property names (not the full binding path). Therefore if the
181      * property name appears multiple times in the view, all instances will be set as read only
182      * </p>
183      *
184      * @return List<String> read only property names
185      * @see View#isSupportsRequestOverrideOfReadOnlyFields()
186      */
187     public List<String> getReadOnlyFieldsList();
188 
189     /**
190      * Setter for the list of read only fields
191      *
192      * @param readOnlyFieldsList
193      */
194     public void setReadOnlyFieldsList(List<String> readOnlyFieldsList);
195 
196     /**
197      * Holds instances for collection add lines. The key of the Map gives the
198      * collection name the line instance applies to, the Map value is an
199      * instance of the collection object class that holds the new line data
200      *
201      * @return Map<String, Object> new collection lines
202      */
203     public Map<String, Object> getNewCollectionLines();
204 
205     /**
206      * Setter for the new collection lines Map
207      *
208      * @param newCollectionLines
209      */
210     public void setNewCollectionLines(Map<String, Object> newCollectionLines);
211 
212     /**
213      * Map of parameters sent for the invoked action
214      *
215      * <p>
216      * Many times besides just setting the method to call actions need to send
217      * additional parameters. For instance the method being called might do a
218      * redirect, in which case the action needs to send parameters for the
219      * redirect URL. An example of this is redirecting to a <code>Lookup</code>
220      * view. In some cases the parameters that need to be sent conflict with
221      * properties already on the form, and putting all the action parameters as
222      * form properties would grow massive (in addition to adds an additional
223      * step from the XML config). So this general map solves those issues.
224      * </p>
225      *
226      * @return Map<String, String> action parameters
227      */
228     public Map<String, String> getActionParameters();
229 
230     /**
231      * Setter for the action parameters map
232      *
233      * @param actionParameters
234      */
235     public void setActionParameters(Map<String, String> actionParameters);
236 
237     /**
238      * Map that is populated from the component state maintained on the client
239      *
240      * <p>
241      * Used when a request is made that refreshes part of the view. The current state for components (which
242      * have state that can be changed on the client), is populated into this map which is then used by the
243      * <code>ViewHelperService</code> to update the components so that the state is maintained when they render.
244      * </p>
245      *
246      * @return Map<String, Object> map where key is name of property or component id, and value is the property
247      *         value or another map of component key/value pairs
248      */
249     public Map<String, Object> getClientStateForSyncing();
250 
251     /**
252      * Holds Set of String identifiers for lines that were selected in a collection
253      *
254      * <p>
255      * When the select field is enabled for a <code>CollectionGroup</code>, the framework will be
256      * default bind the selected identifier strings to this property. The key of the map uniquely identifies the
257      * collection by the full binding path to the collection, and the value is a set of Strings for the checked
258      * lines.
259      * </p>
260      *
261      * @return Map<String, Set<String>> map of collections and their selected lines
262      * @see org.kuali.rice.krad.service.DataObjectMetaDataService#getDataObjectIdentifierString(java.lang.Object)
263      */
264     public Map<String, Set<String>> getSelectedCollectionLines();
265 
266     /**
267      * Setter for the map that holds selected collection lines
268      *
269      * @param selectedCollectionLines
270      */
271     public void setSelectedCollectionLines(Map<String, Set<String>> selectedCollectionLines);
272 
273     /**
274      * Indicates whether the form has had default values from the configured
275      * <code>View</code> applied. This happens only once for each form instance
276      *
277      * @return boolean true if default values have been applied, false if not
278      */
279     public boolean isDefaultsApplied();
280 
281     /**
282      * Setter for the defaults applied indicator
283      *
284      * @param defaultsApplied
285      */
286     public void setDefaultsApplied(boolean defaultsApplied);
287 
288     /**
289      * Script that will run on render (view or component) for generating growl messages
290      *
291      * @return String JS growl script
292      */
293     public String getGrowlScript();
294 
295     /**
296      * Setter for the script that generates growls on render
297      *
298      * @param growlScript
299      */
300     public void setGrowlScript(String growlScript);
301 
302     /**
303      * Script that will run on render (view or component) for a lightbox
304      *
305      * @return String JS lightbox script
306      */
307     public String getLightboxScript();
308 
309     /**
310      * Setter for the script that generates a lightbox on render
311      *
312      * @param lightboxScript
313      */
314     public void setLightboxScript(String lightboxScript);
315 
316     /**
317      * Gets the state.  This is the default location for state on KRAD forms.
318      *
319      * @return the state
320      */
321     public String getState();
322 
323     /**
324      * Set the state
325      *
326      * @param state
327      */
328     public void setState(String state);
329 
330     /**
331      * Indicates whether the request was made by an ajax call
332      *
333      * <p>
334      * Depending on whether the request was made via ajax (versus standard browser submit) the response
335      * will be handled different. For example with an ajax request we can send back partial page updates, which
336      * cannot be done with standard submits
337      * </p>
338      *
339      * <p>
340      * If this indicator is true, {@link #getAjaxReturnType()} will be used to determine how to handling
341      * the ajax return
342      * </p>
343      *
344      * @return boolean true if the request was an ajax call, false if not
345      */
346     public boolean isAjaxRequest();
347 
348     /**
349      * Set the ajaxRequest
350      *
351      * @param ajaxRequest
352      */
353     public void setAjaxRequest(boolean ajaxRequest);
354 
355     /**
356      * Gets the return type for the ajax call
357      *
358      * <p>
359      * The ajax return type indicates how the response content will be handled in the client. Typical
360      * examples include updating a component, the page, or doing a redirect.
361      * </p>
362      *
363      * @return String return type
364      * @see org.kuali.rice.krad.uif.UifConstants.AjaxReturnTypes
365      */
366     public String getAjaxReturnType();
367 
368     /**
369      * Indicates whether the request is to update a component (only applicable for ajax requests)
370      *
371      * @return boolean true if the request is for update component, false if not
372      */
373     public boolean isUpdateComponentRequest();
374 
375     /**
376      * Indicates whether the request is to update a page (only applicable for ajax requests)
377      *
378      * @return boolean true if the request is for update page, false if not
379      */
380     public boolean isUpdatePageRequest();
381 
382     /**
383      * Indicates whether the request is for a non-update of the view (only applicable for ajax requests)
384      *
385      * <p>
386      * Examples of requests that do not update the view are ajax queries or requests that download a file
387      * </p>
388      *
389      * @return boolean true if the request is for non-update, false if not
390      */
391     public boolean isUpdateNoneRequest();
392 
393     public boolean isBuildViewRequest();
394 
395     public boolean isUpdateViewRequest();
396 
397     /**
398      * Setter for the type of ajax return
399      *
400      * @param ajaxReturnType
401      */
402     public void setAjaxReturnType(String ajaxReturnType);
403 }