View Javadoc

1   /**
2    * Copyright 2005-2014 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.web.form;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  import org.codehaus.jackson.map.ObjectMapper;
22  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
23  import org.kuali.rice.krad.uif.UifConstants;
24  import org.kuali.rice.krad.uif.UifParameters;
25  import org.kuali.rice.krad.uif.util.SessionTransient;
26  import org.kuali.rice.krad.uif.view.DialogManager;
27  import org.kuali.rice.krad.uif.view.History;
28  import org.kuali.rice.krad.uif.view.HistoryEntry;
29  import org.kuali.rice.krad.uif.view.View;
30  import org.kuali.rice.krad.uif.service.ViewService;
31  import org.kuali.rice.krad.uif.view.ViewModel;
32  import org.kuali.rice.krad.util.KRADUtils;
33  import org.springframework.web.multipart.MultipartFile;
34  import org.kuali.rice.krad.uif.UifConstants.ViewType;
35  
36  import javax.servlet.http.HttpServletRequest;
37  import java.io.IOException;
38  import java.util.ArrayList;
39  import java.util.HashMap;
40  import java.util.List;
41  import java.util.Map;
42  import java.util.Properties;
43  import java.util.Set;
44  import java.util.UUID;
45  
46  /**
47   * Base form class for views within the KRAD User Interface Framework
48   *
49   * <p>
50   * Holds properties necessary to determine the {@code View} instance that
51   * will be used to render the UI
52   * </p>
53   *
54   * @author Kuali Rice Team (rice.collab@kuali.org)
55   */
56  public class UifFormBase implements ViewModel {
57      private static final long serialVersionUID = 8432543267099454434L;
58  
59      // logger
60      private static final Log LOG = LogFactory.getLog(UifFormBase.class);
61  
62      // current view
63      protected String viewId;
64      protected String viewName;
65      protected ViewType viewTypeName;
66      protected String pageId;
67      protected String methodToCall;
68      protected String formKey;
69  
70      @SessionTransient
71      protected String jumpToId;
72      @SessionTransient
73      protected String jumpToName;
74      @SessionTransient
75      protected String focusId;
76  
77      protected String formPostUrl;
78  
79      protected String state;
80      protected boolean defaultsApplied;
81      protected boolean renderedInLightBox;
82  
83      @SessionTransient
84      protected String growlScript;
85      @SessionTransient
86      protected String lightboxScript;
87  
88      protected View view;
89      protected View postedView;
90  
91      protected Map<String, String> viewRequestParameters;
92      protected List<String> readOnlyFieldsList;
93      protected Map<String, Object> newCollectionLines;
94  
95      @SessionTransient
96      protected Map<String, String> actionParameters;
97      protected Map<String, Object> clientStateForSyncing;
98      @SessionTransient
99      protected Map<String, Set<String>> selectedCollectionLines;
100 
101     protected List<Object> addedCollectionItems;
102 
103     protected MultipartFile attachmentFile;
104 
105     // navigation
106     protected String returnLocation;
107     protected String returnFormKey;
108 
109     @SessionTransient
110     protected boolean ajaxRequest;
111     @SessionTransient
112     protected String ajaxReturnType;
113 
114     protected History formHistory;
115 
116     // dialog fields
117     @SessionTransient
118     protected String dialogExplanation;
119     @SessionTransient
120     protected String dialogResponse;
121     protected DialogManager dialogManager;
122 
123     @SessionTransient
124     protected boolean requestRedirected;
125     @SessionTransient
126     protected String updateComponentId;
127 
128     public UifFormBase() {
129         formKey = generateFormKey();
130         defaultsApplied = false;
131         renderedInLightBox = false;
132         requestRedirected = false;
133 
134         readOnlyFieldsList = new ArrayList<String>();
135         viewRequestParameters = new HashMap<String, String>();
136         newCollectionLines = new HashMap<String, Object>();
137         actionParameters = new HashMap<String, String>();
138         clientStateForSyncing = new HashMap<String, Object>();
139         selectedCollectionLines = new HashMap<String, Set<String>>();
140         addedCollectionItems = new ArrayList();
141         dialogManager = new DialogManager();
142     }
143 
144     /**
145      * Creates the unique id used to store this "conversation" in the session.
146      * The default method generates a java UUID.
147      *
148      * @return
149      */
150     protected String generateFormKey() {
151         return UUID.randomUUID().toString();
152     }
153 
154     /**
155      * @see org.kuali.rice.krad.uif.view.ViewModel#postBind(javax.servlet.http.HttpServletRequest)
156      */
157     @Override
158     public void postBind(HttpServletRequest request) {
159         // default form post URL to request URL
160         formPostUrl = request.getRequestURL().toString();
161 
162         // get any sent client view state and parse into map
163         if (request.getParameterMap().containsKey(UifParameters.CLIENT_VIEW_STATE)) {
164             String clientStateJSON = request.getParameter(UifParameters.CLIENT_VIEW_STATE);
165             if (StringUtils.isNotBlank(clientStateJSON)) {
166                 // change single quotes to double quotes (necessary because the reverse was done for sending)
167                 clientStateJSON = StringUtils.replace(clientStateJSON, "'", "\"");
168 
169                 ObjectMapper mapper = new ObjectMapper();
170                 try {
171                     clientStateForSyncing = mapper.readValue(clientStateJSON, Map.class);
172                 } catch (IOException e) {
173                     throw new RuntimeException("Unable to decode client side state JSON", e);
174                 }
175             }
176         }
177 
178         // populate read only fields list
179         if (request.getParameter(UifParameters.READ_ONLY_FIELDS) != null) {
180             String readOnlyFields = request.getParameter(UifParameters.READ_ONLY_FIELDS);
181             setReadOnlyFieldsList(KRADUtils.convertStringParameterToList(readOnlyFields));
182         }
183     }
184 
185     /**
186      * @see org.kuali.rice.krad.uif.view.ViewModel#getViewId()
187      */
188     @Override
189     public String getViewId() {
190         return this.viewId;
191     }
192 
193     /**
194      * @see org.kuali.rice.krad.uif.view.ViewModel#setViewId(java.lang.String)
195      */
196     @Override
197     public void setViewId(String viewId) {
198         this.viewId = viewId;
199     }
200 
201     /**
202      * @see org.kuali.rice.krad.uif.view.ViewModel#getViewName()
203      */
204     @Override
205     public String getViewName() {
206         return this.viewName;
207     }
208 
209     /**
210      * @see org.kuali.rice.krad.uif.view.ViewModel#setViewName(java.lang.String)
211      */
212     @Override
213     public void setViewName(String viewName) {
214         this.viewName = viewName;
215     }
216 
217     /**
218      * @see org.kuali.rice.krad.uif.view.ViewModel#getViewTypeName()
219      */
220     @Override
221     public ViewType getViewTypeName() {
222         return this.viewTypeName;
223     }
224 
225     /**
226      * @see org.kuali.rice.krad.uif.view.ViewModel#setViewTypeName(org.kuali.rice.krad.uif.UifConstants.ViewType)
227      */
228     @Override
229     public void setViewTypeName(ViewType viewTypeName) {
230         this.viewTypeName = viewTypeName;
231     }
232 
233     /**
234      * @see org.kuali.rice.krad.uif.view.ViewModel#getPageId()
235      */
236     @Override
237     public String getPageId() {
238         return this.pageId;
239     }
240 
241     /**
242      * @see org.kuali.rice.krad.uif.view.ViewModel#setPageId(java.lang.String)
243      */
244     @Override
245     public void setPageId(String pageId) {
246         this.pageId = pageId;
247     }
248 
249     /**
250      * @see org.kuali.rice.krad.uif.view.ViewModel#getFormPostUrl()
251      */
252     @Override
253     public String getFormPostUrl() {
254         return this.formPostUrl;
255     }
256 
257     /**
258      * @see org.kuali.rice.krad.uif.view.ViewModel#setFormPostUrl(java.lang.String)
259      */
260     @Override
261     public void setFormPostUrl(String formPostUrl) {
262         this.formPostUrl = formPostUrl;
263     }
264 
265     public String getReturnLocation() {
266         return this.returnLocation;
267     }
268 
269     public void setReturnLocation(String returnLocation) {
270         this.returnLocation = returnLocation;
271     }
272 
273     public String getReturnFormKey() {
274         return this.returnFormKey;
275     }
276 
277     public void setReturnFormKey(String returnFormKey) {
278         this.returnFormKey = returnFormKey;
279     }
280 
281     /**
282      * Identifies the controller method that should be invoked to fulfill a
283      * request. The value will be matched up against the 'params' setting on the
284      * {@code RequestMapping} annotation for the controller method
285      *
286      * @return String method to call
287      */
288     public String getMethodToCall() {
289         return this.methodToCall;
290     }
291 
292     /**
293      * Setter for the method to call
294      *
295      * @param methodToCall
296      */
297     public void setMethodToCall(String methodToCall) {
298         this.methodToCall = methodToCall;
299     }
300 
301     /**
302      * @see org.kuali.rice.krad.uif.view.ViewModel#getViewRequestParameters()
303      */
304     @Override
305     public Map<String, String> getViewRequestParameters() {
306         return this.viewRequestParameters;
307     }
308 
309     /**
310      * @see org.kuali.rice.krad.uif.view.ViewModel#setViewRequestParameters(java.util.Map<java.lang.String,java.lang.String>)
311      */
312     @Override
313     public void setViewRequestParameters(Map<String, String> viewRequestParameters) {
314         this.viewRequestParameters = viewRequestParameters;
315     }
316 
317     /**
318      * @see org.kuali.rice.krad.uif.view.ViewModel#getReadOnlyFieldsList()
319      */
320     @Override
321     public List<String> getReadOnlyFieldsList() {
322         return readOnlyFieldsList;
323     }
324 
325     /**
326      * @see org.kuali.rice.krad.uif.view.ViewModel#setReadOnlyFieldsList(java.util.List<java.lang.String>)
327      */
328     @Override
329     public void setReadOnlyFieldsList(List<String> readOnlyFieldsList) {
330         this.readOnlyFieldsList = readOnlyFieldsList;
331     }
332 
333     /**
334      * @see org.kuali.rice.krad.uif.view.ViewModel#getNewCollectionLines()
335      */
336     @Override
337     public Map<String, Object> getNewCollectionLines() {
338         return this.newCollectionLines;
339     }
340 
341     /**
342      * @see org.kuali.rice.krad.uif.view.ViewModel#setNewCollectionLines(java.util.Map<java.lang.String,java.lang.Object>)
343      */
344     @Override
345     public void setNewCollectionLines(Map<String, Object> newCollectionLines) {
346         this.newCollectionLines = newCollectionLines;
347     }
348 
349     /**
350      * @see org.kuali.rice.krad.uif.view.ViewModel#getActionParameters()
351      */
352     @Override
353     public Map<String, String> getActionParameters() {
354         return this.actionParameters;
355     }
356 
357     /**
358      * Returns the action parameters map as a {@code Properties} instance
359      *
360      * @return Properties action parameters
361      */
362     public Properties getActionParametersAsProperties() {
363         return KRADUtils.convertMapToProperties(actionParameters);
364     }
365 
366     /**
367      * @see org.kuali.rice.krad.uif.view.ViewModel#setActionParameters(java.util.Map<java.lang.String,java.lang.String>)
368      */
369     @Override
370     public void setActionParameters(Map<String, String> actionParameters) {
371         this.actionParameters = actionParameters;
372     }
373 
374     /**
375      * Retrieves the value for the given action parameter, or empty string if
376      * not found
377      *
378      * @param actionParameterName - name of the action parameter to retrieve value for
379      * @return String parameter value or empty string
380      */
381     public String getActionParamaterValue(String actionParameterName) {
382         if ((actionParameters != null) && actionParameters.containsKey(actionParameterName)) {
383             return actionParameters.get(actionParameterName);
384         }
385 
386         return "";
387     }
388 
389     /**
390      * Returns the action event that was sent in the action parameters (if any)
391      *
392      * <p>
393      * The action event is a special action parameter that can be sent to indicate a type of action being taken. This
394      * can be looked at by the view or components to render differently
395      * </p>
396      *
397      * TODO: make sure action parameters are getting reinitialized on each request
398      *
399      * @return String action event name or blank if action event was not sent
400      */
401     public String getActionEvent() {
402         if ((actionParameters != null) && actionParameters.containsKey(UifConstants.UrlParams.ACTION_EVENT)) {
403             return actionParameters.get(UifConstants.UrlParams.ACTION_EVENT);
404         }
405 
406         return "";
407     }
408 
409     /**
410      * @see org.kuali.rice.krad.uif.view.ViewModel#getClientStateForSyncing()
411      */
412     @Override
413     public Map<String, Object> getClientStateForSyncing() {
414         return clientStateForSyncing;
415     }
416 
417     /**
418      * Setter for the client state
419      *
420      * @param clientStateForSyncing
421      */
422     public void setClientStateForSyncing(Map<String, Object> clientStateForSyncing) {
423         this.clientStateForSyncing = clientStateForSyncing;
424     }
425 
426     /**
427      * @see org.kuali.rice.krad.uif.view.ViewModel#getSelectedCollectionLines()
428      */
429     @Override
430     public Map<String, Set<String>> getSelectedCollectionLines() {
431         return selectedCollectionLines;
432     }
433 
434     /**
435      * @see org.kuali.rice.krad.uif.view.ViewModel#setSelectedCollectionLines(java.util.Map<java.lang.String,java.util.Set<java.lang.String>>)
436      */
437     @Override
438     public void setSelectedCollectionLines(Map<String, Set<String>> selectedCollectionLines) {
439         this.selectedCollectionLines = selectedCollectionLines;
440     }
441 
442     /**
443      * Key string that identifies the form instance in session storage
444      *
445      * <p>
446      * When the view is posted, the previous form instance is retrieved and then
447      * populated from the request parameters. This key string is retrieve the
448      * session form from the session service
449      * </p>
450      *
451      * @return String form session key
452      */
453     public String getFormKey() {
454         return this.formKey;
455     }
456 
457     /**
458      * Setter for the form's session key
459      *
460      * @param formKey
461      */
462     public void setFormKey(String formKey) {
463         this.formKey = formKey;
464     }
465 
466     /**
467      * @see org.kuali.rice.krad.uif.view.ViewModel#isDefaultsApplied()
468      */
469     @Override
470     public boolean isDefaultsApplied() {
471         return this.defaultsApplied;
472     }
473 
474     /**
475      * @see org.kuali.rice.krad.uif.view.ViewModel#setDefaultsApplied(boolean)
476      */
477     @Override
478     public void setDefaultsApplied(boolean defaultsApplied) {
479         this.defaultsApplied = defaultsApplied;
480     }
481 
482     /**
483      * Indicates whether a redirect has been requested for the view
484      *
485      * @return boolean true if redirect was requested, false if not
486      */
487     public boolean isRequestRedirected() {
488         return requestRedirected;
489     }
490 
491     /**
492      * Setter for the request redirect indicator
493      *
494      * @param requestRedirected
495      */
496     public void setRequestRedirected(boolean requestRedirected) {
497         this.requestRedirected = requestRedirected;
498     }
499 
500     /**
501      * Holder for files that are attached through the view
502      *
503      * @return MultipartFile representing the attachment
504      */
505     public MultipartFile getAttachmentFile() {
506         return this.attachmentFile;
507     }
508 
509     /**
510      * Setter for the form's attachment file
511      *
512      * @param attachmentFile
513      */
514     public void setAttachmentFile(MultipartFile attachmentFile) {
515         this.attachmentFile = attachmentFile;
516     }
517 
518     /**
519      * Id for the component that should be updated for a component refresh process
520      *
521      * @return String component id
522      */
523     public String getUpdateComponentId() {
524         return updateComponentId;
525     }
526 
527     /**
528      * Setter for the component id that should be refreshed
529      *
530      * @param updateComponentId
531      */
532     public void setUpdateComponentId(String updateComponentId) {
533         this.updateComponentId = updateComponentId;
534     }
535 
536     /**
537      * @see org.kuali.rice.krad.uif.view.ViewModel#getView()
538      */
539     @Override
540     public View getView() {
541         return this.view;
542     }
543 
544     /**
545      * @see org.kuali.rice.krad.uif.view.ViewModel#setView(org.kuali.rice.krad.uif.view.View)
546      */
547     @Override
548     public void setView(View view) {
549         this.view = view;
550     }
551 
552     /**
553      * @see org.kuali.rice.krad.uif.view.ViewModel#getPostedView()
554      */
555     @Override
556     public View getPostedView() {
557         return this.postedView;
558     }
559 
560     /**
561      * @see org.kuali.rice.krad.uif.view.ViewModel#setPostedView(org.kuali.rice.krad.uif.view.View)
562      */
563     @Override
564     public void setPostedView(View postedView) {
565         this.postedView = postedView;
566     }
567 
568     /**
569      * Instance of the {@code ViewService} that can be used to retrieve
570      * {@code View} instances
571      *
572      * @return ViewService implementation
573      */
574     protected ViewService getViewService() {
575         return KRADServiceLocatorWeb.getViewService();
576     }
577 
578     /**
579      * The jumpToId for this form, the element with this id will be jumped to automatically
580      * when the form is loaded in the view.
581      * Using "TOP" or "BOTTOM" will jump to the top or the bottom of the resulting page.
582      * jumpToId always takes precedence over jumpToName, if set.
583      *
584      * @return the jumpToId
585      */
586     public String getJumpToId() {
587         return this.jumpToId;
588     }
589 
590     /**
591      * @param jumpToId the jumpToId to set
592      */
593     public void setJumpToId(String jumpToId) {
594         this.jumpToId = jumpToId;
595     }
596 
597     /**
598      * The jumpToName for this form, the element with this name will be jumped to automatically
599      * when the form is loaded in the view.
600      * WARNING: jumpToId always takes precedence over jumpToName, if set.
601      *
602      * @return the jumpToName
603      */
604     public String getJumpToName() {
605         return this.jumpToName;
606     }
607 
608     /**
609      * @param jumpToName the jumpToName to set
610      */
611     public void setJumpToName(String jumpToName) {
612         this.jumpToName = jumpToName;
613     }
614 
615     /**
616      * Field to place focus on when the page loads
617      * An empty focusId will result in focusing on the first visible input element by default.
618      *
619      * @return the focusId
620      */
621     public String getFocusId() {
622         return this.focusId;
623     }
624 
625     /**
626      * @param focusId the focusId to set
627      */
628     public void setFocusId(String focusId) {
629         this.focusId = focusId;
630     }
631 
632     /**
633      * History parameter representing the History of views that have come before the
634      * viewing of the current view
635      *
636      * <p>
637      * Used for breadcrumb widget generation on the view and also for navigating back
638      * to previous or hub locations
639      * </p>
640      *
641      * @return History instance giving current history
642      */
643     public History getFormHistory() {
644         return formHistory;
645     }
646 
647     /**
648      * Setter for the current History object
649      *
650      * @param history the history to set
651      */
652     public void setFormHistory(History history) {
653         this.formHistory = history;
654     }
655 
656     /**
657      * Indicates whether the view is rendered within a lightbox
658      *
659      * <p>
660      * Some discussion (for example how a close button behaves) need to change based on whether the
661      * view is rendered within a lightbox or the standard browser window. This boolean is true when it is
662      * within a lightbox
663      * </p>
664      *
665      * @return boolean true if view is rendered within a lightbox, false if not
666      */
667     public boolean isRenderedInLightBox() {
668         return this.renderedInLightBox;
669     }
670 
671     /**
672      * Setter for the rendered within lightbox indicator
673      *
674      * @param renderedInLightBox
675      */
676     public void setRenderedInLightBox(boolean renderedInLightBox) {
677         this.renderedInLightBox = renderedInLightBox;
678     }
679 
680     /**
681      * @see org.kuali.rice.krad.uif.view.ViewModel#getGrowlScript()
682      */
683     @Override
684     public String getGrowlScript() {
685         return growlScript;
686     }
687 
688     /**
689      * @see org.kuali.rice.krad.uif.view.ViewModel#setGrowlScript(java.lang.String)
690      */
691     @Override
692     public void setGrowlScript(String growlScript) {
693         this.growlScript = growlScript;
694     }
695 
696     /**
697      * @see org.kuali.rice.krad.uif.view.ViewModel#getState()
698      */
699     public String getState() {
700         return state;
701     }
702 
703     /**
704      * @see ViewModel#setState(String)
705      */
706     public void setState(String state) {
707         this.state = state;
708     }
709 
710     /**
711      * @see org.kuali.rice.krad.uif.view.ViewModel#getLightboxScript()
712      */
713     @Override
714     public String getLightboxScript() {
715         return lightboxScript;
716     }
717 
718     /**
719      * @see org.kuali.rice.krad.uif.view.ViewModel#setLightboxScript(java.lang.String)
720      */
721     @Override
722     public void setLightboxScript(String lightboxScript) {
723         this.lightboxScript = lightboxScript;
724     }
725 
726     /**
727      * @see org.kuali.rice.krad.uif.view.ViewModel#isAjaxRequest()
728      */
729     @Override
730     public boolean isAjaxRequest() {
731         return ajaxRequest;
732     }
733 
734      /**
735      * @see org.kuali.rice.krad.uif.view.ViewModel#setAjaxRequest(boolean)
736      */
737     @Override
738     public void setAjaxRequest(boolean ajaxRequest) {
739         this.ajaxRequest = ajaxRequest;
740     }
741 
742      /**
743      * @see org.kuali.rice.krad.uif.view.ViewModel#getAjaxReturnType()
744      */
745     @Override
746     public String getAjaxReturnType() {
747         return ajaxReturnType;
748     }
749 
750     /**
751      * @see org.kuali.rice.krad.uif.view.ViewModel#isUpdateComponentRequest()
752      */
753     @Override
754     public boolean isUpdateComponentRequest() {
755         return isAjaxRequest() && StringUtils.isNotBlank(getAjaxReturnType()) && getAjaxReturnType().equals(
756                 UifConstants.AjaxReturnTypes.UPDATECOMPONENT.getKey());
757     }
758 
759     /**
760      * @see org.kuali.rice.krad.uif.view.ViewModel#isUpdateDialogRequest()
761      */
762     @Override
763     public boolean isUpdateDialogRequest() {
764         return isAjaxRequest() && StringUtils.isNotBlank(getAjaxReturnType()) && getAjaxReturnType().equals(
765                 UifConstants.AjaxReturnTypes.UPDATEDIALOG.getKey());
766     }
767 
768     /**
769      * @see org.kuali.rice.krad.uif.view.ViewModel#isUpdatePageRequest()
770      */
771     @Override
772     public boolean isUpdatePageRequest() {
773         return isAjaxRequest() && StringUtils.isNotBlank(getAjaxReturnType()) && getAjaxReturnType().equals(
774                 UifConstants.AjaxReturnTypes.UPDATEPAGE.getKey());
775     }
776 
777     /**
778      * @see org.kuali.rice.krad.uif.view.ViewModel#isUpdateNoneRequest()
779      */
780     @Override
781     public boolean isUpdateNoneRequest() {
782         return isAjaxRequest() && StringUtils.isNotBlank(getAjaxReturnType()) && getAjaxReturnType().equals(
783                 UifConstants.AjaxReturnTypes.UPDATENONE.getKey());
784     }
785 
786     /**
787      * @see org.kuali.rice.krad.uif.view.ViewModel#isBuildViewRequest()
788      */
789     @Override
790     public boolean isBuildViewRequest() {
791         return !isAjaxRequest() || (StringUtils.isNotBlank(getAjaxReturnType()) && (getAjaxReturnType().equals(
792                 UifConstants.AjaxReturnTypes.UPDATEVIEW.getKey()) || isUpdatePageRequest()));
793     }
794 
795     /**
796      * @see org.kuali.rice.krad.uif.view.ViewModel#isUpdateViewRequest()
797      */
798     @Override
799     public boolean isUpdateViewRequest() {
800         return isAjaxRequest() &&
801                 StringUtils.isNotBlank(getAjaxReturnType()) &&
802                 (isUpdateComponentRequest() || getAjaxReturnType().equals(
803                         UifConstants.AjaxReturnTypes.DISPLAYLIGHTBOX.getKey()));
804     }
805 
806     /**
807      * @see org.kuali.rice.krad.uif.view.ViewModel#setAjaxReturnType(java.lang.String)
808      */
809     @Override
810     public void setAjaxReturnType(String ajaxReturnType) {
811         this.ajaxReturnType = ajaxReturnType;
812     }
813 
814     /**
815      * Returns the String entered by the user when presented a dialog
816      *
817      * <p>
818      * Field defined here so all forms will be able to bind to a dialog using the same property
819      * </p>
820      *
821      * @return String - the text entered by a user as a reply in a modal dialog.
822      */
823     public String getDialogExplanation() {
824         return dialogExplanation;
825     }
826 
827     /**
828      * Sets the dialogExplanation text value.
829      *
830      * @param dialogExplanation - text entered by user when replying to a modal dialog
831      */
832     public void setDialogExplanation(String dialogExplanation) {
833         this.dialogExplanation = dialogExplanation;
834     }
835 
836     /**
837      * Represents the option chosen by the user when interacting with a modal dialog
838      *
839      * <p>
840      * This is used to determine which option was chosen by the user. The value is the key in the key/value pair
841      * selected in the control.
842      * </p>
843      *
844      * @return - String key selected by the user
845      */
846     public String getDialogResponse() {
847         return dialogResponse;
848     }
849 
850     /**
851      * Sets the response key text selected by the user as a response to a modal dialog
852      *
853      * @param dialogResponse - the key of the option chosen by the user
854      */
855     public void setDialogResponse(String dialogResponse) {
856         this.dialogResponse = dialogResponse;
857     }
858 
859     /**
860      * Gets the DialogManager for this view/form
861      *
862      * <p>
863      * The DialogManager tracks modal dialog interactions with the user
864      * </p>
865      * @return
866      */
867     public DialogManager getDialogManager() {
868         return dialogManager;
869     }
870 
871     /**
872      * Sets the DialogManager for this view
873      *
874      * @param dialogManager - DialogManager instance for this view
875      */
876     public void setDialogManager(DialogManager dialogManager) {
877         this.dialogManager = dialogManager;
878     }
879 
880 
881     /**
882      * The {@code List} that contains all newly added items for the collections on the model
883      *
884      * <p>
885      * This list contains the new items for all the collections on the model.
886      * </p>
887      *
888      * @return List of the newly added item lists
889      */
890     public List getAddedCollectionItems() {
891         return addedCollectionItems;
892     }
893 
894     /**
895      * Setter for the newly added item list
896      *
897      * @param addedCollectionItems
898      */
899     public void setAddedCollectionItems(List addedCollectionItems) {
900         this.addedCollectionItems = addedCollectionItems;
901     }
902 
903     /**
904      * Indicates whether an collection item has been newly added
905      *
906      * <p>
907      * Tests collection items against the list of newly added items on the model. This list gets cleared when the view
908      * is submitted and the items are persisted.
909      * </p>
910      *
911      * @param item - the item to test against list of newly added items
912      * @return boolean true if the item has been newly added
913      */
914     public boolean isAddedCollectionItem(Object item) {
915         return addedCollectionItems.contains(item);
916     }
917 
918 }