001 /**
002 * Copyright 2005-2013 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.web.bind;
017
018 import org.kuali.rice.krad.web.form.UifFormBase;
019 import org.springframework.web.bind.ServletRequestDataBinder;
020 import org.springframework.web.bind.support.WebBindingInitializer;
021 import org.springframework.web.context.request.NativeWebRequest;
022 import org.springframework.web.method.support.InvocableHandlerMethod;
023 import org.springframework.web.servlet.mvc.method.annotation.ServletRequestDataBinderFactory;
024
025 import java.util.List;
026
027 /**
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030 public class UifServletRequestDataBinderFactory extends ServletRequestDataBinderFactory {
031
032 /**
033 * Create a new instance.
034 *
035 * @param binderMethods one or more {@code @InitBinder} methods
036 * @param initializer provides global data binder initialization
037 */
038 public UifServletRequestDataBinderFactory(List<InvocableHandlerMethod> binderMethods,
039 WebBindingInitializer initializer) {
040 super(binderMethods, initializer);
041 }
042
043 @Override
044 protected ServletRequestDataBinder createBinderInstance(Object target, String objectName,
045 NativeWebRequest request) {
046 if (target != null) {
047 // only override for UifFormBase models so that non KRAD spring MVC
048 // can be used in same dispatcher servlet.
049 if (target instanceof UifFormBase) {
050 return new UifServletRequestDataBinder(target, objectName);
051 }
052 }
053
054 return super.createBinderInstance(target, objectName, request);
055 }
056 }