View Javadoc
1   /**
2    * Copyright 2005-2016 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.bind;
17  
18  import org.kuali.rice.krad.uif.view.ViewModel;
19  import org.springframework.beans.BeanWrapper;
20  import org.springframework.util.Assert;
21  import org.springframework.validation.BeanPropertyBindingResult;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.HashSet;
26  import java.util.List;
27  import java.util.Set;
28  
29  /**
30   * This is a description of what this class does - swgibson don't forget to fill this in.
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class UifBeanPropertyBindingResult extends BeanPropertyBindingResult {
35      private static final long serialVersionUID = -3740046436620585003L;
36  
37      private final Set<String> modifiedPaths = new HashSet<String>();
38  
39      private boolean changeTracking = false;
40  
41      public UifBeanPropertyBindingResult(Object target, String objectName, boolean autoGrowNestedPaths,
42              int autoGrowCollectionLimit) {
43          super(target, objectName, autoGrowNestedPaths, autoGrowCollectionLimit);
44      }
45  
46      /**
47       * Create a new {@link BeanWrapper} for the underlying target object.
48       *
49       * @see #getTarget()
50       */
51      @Override
52      protected UifViewBeanWrapper createBeanWrapper() {
53          Assert.state(super.getTarget() != null,
54                  "Cannot access properties on null bean instance '" + getObjectName() + "'!");
55          Assert.state(super.getTarget() instanceof ViewModel,
56                  "Object must be instance of ViewModel to use Uif Bean Wrapper");
57  
58          return new UifViewBeanWrapper((ViewModel) super.getTarget(), this);
59      }
60  
61      public Set<String> getModifiedPaths() {
62          return Collections.unmodifiableSet(this.modifiedPaths);
63      }
64  
65      public void addModifiedPath(String path) {
66          this.modifiedPaths.add(path);
67      }
68  
69      public boolean isChangeTracking() {
70          return changeTracking;
71      }
72  
73      public void setChangeTracking(boolean changeTracking) {
74          this.changeTracking = changeTracking;
75      }
76  
77  }