001/** 002 * Copyright 2005-2018 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 */ 016package org.kuali.rice.krad.web.bind; 017 018import org.kuali.rice.krad.uif.view.ViewModel; 019import org.springframework.beans.BeanWrapper; 020import org.springframework.util.Assert; 021import org.springframework.validation.BeanPropertyBindingResult; 022 023import java.util.ArrayList; 024import java.util.Collections; 025import java.util.HashSet; 026import java.util.List; 027import java.util.Set; 028 029/** 030 * This is a description of what this class does - swgibson don't forget to fill this in. 031 * 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034public class UifBeanPropertyBindingResult extends BeanPropertyBindingResult { 035 private static final long serialVersionUID = -3740046436620585003L; 036 037 private final Set<String> modifiedPaths = new HashSet<String>(); 038 039 private boolean changeTracking = false; 040 041 public UifBeanPropertyBindingResult(Object target, String objectName, boolean autoGrowNestedPaths, 042 int autoGrowCollectionLimit) { 043 super(target, objectName, autoGrowNestedPaths, autoGrowCollectionLimit); 044 } 045 046 /** 047 * Create a new {@link BeanWrapper} for the underlying target object. 048 * 049 * @see #getTarget() 050 */ 051 @Override 052 protected UifViewBeanWrapper createBeanWrapper() { 053 Assert.state(super.getTarget() != null, 054 "Cannot access properties on null bean instance '" + getObjectName() + "'!"); 055 Assert.state(super.getTarget() instanceof ViewModel, 056 "Object must be instance of ViewModel to use Uif Bean Wrapper"); 057 058 return new UifViewBeanWrapper((ViewModel) super.getTarget(), this); 059 } 060 061 public Set<String> getModifiedPaths() { 062 return Collections.unmodifiableSet(this.modifiedPaths); 063 } 064 065 public void addModifiedPath(String path) { 066 this.modifiedPaths.add(path); 067 } 068 069 public boolean isChangeTracking() { 070 return changeTracking; 071 } 072 073 public void setChangeTracking(boolean changeTracking) { 074 this.changeTracking = changeTracking; 075 } 076 077}