KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > chain > servlet > PopulateActionForm


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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
17 package org.apache.struts.chain.servlet;
18
19
20 import org.apache.commons.chain.Context;
21 import org.apache.commons.chain.web.servlet.ServletWebContext;
22 import org.apache.struts.Globals;
23 import org.apache.struts.action.ActionForm;
24 import org.apache.struts.action.ActionMapping;
25 import org.apache.struts.chain.AbstractPopulateActionForm;
26 import org.apache.struts.config.ActionConfig;
27 import org.apache.struts.util.RequestUtils;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 /**
32  * <p>Populate the form bean (if any) for this request. Sets the multipart
33  * class from the action config in the request attributes.</p>
34  *
35  * @version $Rev: 54933 $ $Date: 2004-10-16 18:04:52 +0100 (Sat, 16 Oct 2004) $
36  */

37
38 public class PopulateActionForm extends AbstractPopulateActionForm {
39
40
41     private static final Log log = LogFactory.getLog(PopulateActionForm.class);
42
43     // ------------------------------------------------------- Protected Methods
44

45
46     protected void populate(Context context,
47                          ActionConfig actionConfig,
48                          ActionForm actionForm) throws Exception JavaDoc
49     {
50         ServletWebContext swcontext = (ServletWebContext) context;
51         RequestUtils.populate(actionForm, actionConfig.getPrefix(), actionConfig.getSuffix(), swcontext.getRequest());
52     }
53
54     protected void reset(Context context,
55                          ActionConfig actionConfig,
56                          ActionForm actionForm) {
57
58         ServletWebContext swcontext = (ServletWebContext) context;
59         actionForm.reset((ActionMapping) actionConfig, swcontext.getRequest());
60
61         // Set the multipart class
62
if (actionConfig.getMultipartClass() != null) {
63             swcontext.getRequestScope().put(Globals.MULTIPART_KEY,
64                                  actionConfig.getMultipartClass());
65         }
66
67     }
68
69
70 }
71
Popular Tags