KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > actionflow > ActionFlowModelResolver


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.model.actionflow;
8
9
10 import java.util.Map JavaDoc;
11
12 import javax.servlet.http.HttpServletRequest JavaDoc;
13
14 import com.inversoft.beans.BeanException;
15 import com.inversoft.verge.mvc.MVCException;
16 import com.inversoft.verge.mvc.MVCRequest;
17 import com.inversoft.verge.mvc.config.BaseFormConfig;
18 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigStruct;
19 import com.inversoft.verge.mvc.model.ModelResolution;
20 import com.inversoft.verge.mvc.model.ModelResolver;
21 import com.inversoft.verge.util.WebBean;
22
23
24 /**
25  * <p>
26  * This class is the model resolver for actionflow model
27  * objects. This uses the form configuration to locate
28  * model objects.
29  * </p>
30  *
31  * @author Brian Pontarelli
32  * @since 2.0
33  * @version 2.0
34  */

35 public class ActionFlowModelResolver implements ModelResolver {
36
37     /**
38      * Constructor for ActionFlowModelResolver.
39      */

40     public ActionFlowModelResolver() {
41         super();
42     }
43
44
45     /**
46      * <p>
47      * Using the {@link BaseFormConfig BaseFormConfig} fetched by the controller
48      * setupMVCRequest method, this retrieves the FormBean.
49      * </p>
50      *
51      * @param mvcRequest The MVCRequest used while parsing for the http servlet
52      * request stored inside it as well as other objects.
53      * @param definition The Model definition from the request
54      * @param extraParams Not used
55      * @return The ModelResolution for the model object
56      */

57     public ModelResolution resolve(MVCRequest mvcRequest, String JavaDoc definition,
58             Map JavaDoc extraParams)
59     throws MVCException {
60
61         // Check the extraParams first and if it is not there, look it up and
62
// store it
63
HttpServletRequest JavaDoc request = mvcRequest.getRequest();
64         ActionFlowConfigStruct struct = (ActionFlowConfigStruct) mvcRequest.getConfiguration();
65         BaseFormConfig config = struct.baseFormConfig;
66         ActionFlowModelMetaData md = new ActionFlowModelMetaData(definition);
67         WebBean formBean = config.getFormBean(md.getID());
68         ModelResolution mr = null;
69
70         try {
71             mr = new ModelResolution(formBean.getInstance(request), md);
72         } catch (BeanException be) {
73             throw new MVCException(be);
74         }
75
76         return mr;
77     }
78 }
Popular Tags