KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jodd > bean > loader > MultipartRequestWrapperBeanLoader


1 // Copyright (c) 2003-2007, Jodd Team (jodd.sf.net). All Rights Reserved.
2

3 package jodd.bean.loader;
4
5 import jodd.servlet.upload.MultipartRequestWrapper;
6 import jodd.servlet.upload.MultipartRequest;
7
8 import javax.servlet.http.HttpServletRequest JavaDoc;
9
10 /**
11  * Populates java bean from {@link MultipartRequestWrapper} objects.
12  */

13 public class MultipartRequestWrapperBeanLoader implements BeanLoader {
14     private boolean trim;
15
16     public MultipartRequestWrapperBeanLoader() {
17     }
18
19     public MultipartRequestWrapperBeanLoader(boolean trim) {
20         this.trim = trim;
21     }
22
23     public static void loadBean(Object JavaDoc bean, Object JavaDoc request, boolean trim) {
24         if (request instanceof MultipartRequestWrapper) {
25             MultipartRequest mrequest = ((MultipartRequestWrapper) request).getMultipartRequest();
26             if (mrequest != null) {
27                 // multipart
28
MultipartRequestBeanLoader.loadBean(bean, mrequest, trim);
29             } else {
30                 // regular
31
HttpServletRequest JavaDoc req = (HttpServletRequest JavaDoc) ((MultipartRequestWrapper) request).getRequest();
32                 RequestBeanLoader.loadBean(bean, req, trim);
33             }
34         }
35     }
36
37     public void load(Object JavaDoc bean, Object JavaDoc request) {
38         loadBean(bean, request, trim);
39     }
40 }
41
Popular Tags