01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-util/tool-lib/src/java/org/sakaiproject/metaobj/utils/mvc/impl/servlet/ServletRequestBeanDataBinder.java $
03: * $Id: ServletRequestBeanDataBinder.java 14230 2006-09-05 18:02:51Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.utils.mvc.impl.servlet;
21:
22: import javax.servlet.ServletRequest;
23:
24: import org.sakaiproject.metaobj.utils.mvc.impl.BindExceptionBase;
25: import org.springframework.beans.MutablePropertyValues;
26: import org.springframework.validation.BindException;
27: import org.springframework.web.bind.ServletRequestDataBinder;
28: import org.springframework.web.bind.ServletRequestParameterPropertyValues;
29: import org.springframework.web.multipart.MultipartHttpServletRequest;
30:
31: public class ServletRequestBeanDataBinder extends
32: ServletRequestDataBinder {
33: public ServletRequestBeanDataBinder(Object o, String s) {
34: super (o, s);
35: }
36:
37: public void bind(ServletRequest request) {
38: // bind normal HTTP parameters
39: bind(new ServletRequestParameterPropertyValues(request));
40:
41: // bind multipart files
42: if (request instanceof MultipartHttpServletRequest) {
43: MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
44: bind(new MutablePropertyValues(multipartRequest
45: .getFileMap()));
46: }
47: }
48:
49: protected BindException createErrors(Object target, String name) {
50: return new BindExceptionBase(target, name);
51: }
52: }
|