1    package com.instantbank.servicing.control.web.handlers;
2    
3    import java.util.HashMap;
4    import java.util.ArrayList;
5    import java.util.Enumeration;
6    import java.util.Hashtable;
7    import java.util.StringTokenizer;
8    
9    import javax.servlet.http.HttpServletRequest;
10   import javax.servlet.http.HttpSession;
11   import javax.servlet.ServletContext;
12   import com.instantbank.common.utilcomponents.CodeDescription;
13   import com.instantbank.servicing.control.event.SetParameterXValueEvent;
14   import com.instantbank.servicing.control.util.JSPUtil;
15   import com.instantbank.servicing.control.util.WebKeys;
16   import com.instantbank.common.utilcomponents.Debug;
17   import com.instantbank.common.utilcomponents.ServicingGlobals;
18   import com.instantbank.servicing.control.ServicingEventException;
19   import com.instantbank.component.parameter.util.*;
20   
21   
22   /**
23    *  Set Parameter Values: flow handler for deciding output screen after
24    *  processing an action
25    *
26    * @author Instant-bank (Jorge Cardenas)
27    * @created October 2002
28    */
29   public class SetParameterXValueFlowHandler
30       implements FlowHandler {
31     private Debug debug = null;
32   
33   
34     /**
35      *  optional execution before processFlow method
36      *
37      * @param request HTTP request
38      */
39     public void doStart(HttpServletRequest request) { }
40   
41   
42     /**
43      *  principal method for deciding output screen after processing an action
44      *
45      * @param request of MainServlet
46      * @param answer of the action
47      * @param context web context
48      * @return String with the number of the  output screen
49      * @exception ServicingEventException
50      */
51     public String processFlow(HttpServletRequest request, Object answer,
52                               ServletContext context)
53        throws ServicingEventException {
54   
55       debug = new Debug();
56       debug.setDebugginOn(true);
57       debug.setPreMessage("** SetParameterXValueFlowHandler: ");
58       debug.println("processFlow");
59   
60       String nextScreen = null;
61       SetParameterXValueEvent ce = null;
62   
63       if(request.getAttribute(WebKeys.SetParameterXValueEvent) != null) {
64         ce = (SetParameterXValueEvent)request.getAttribute(WebKeys.SetParameterXValueEvent);
65       }
66   
67       if(request.getAttribute(WebKeys.ExceptionOcurred) != null) {
68         nextScreen = "1";  // SETPARAMETERXVALUE_PROBLEM
69   
70       }
71       else if(((String)request.getAttribute(WebKeys.SetParametersValues)).equals("list")) {
72         request.setAttribute
73           (WebKeys.SetParametersValues, "nolist");
74         nextScreen = "3";  // SETPARAMETERSVALUES_MAIN
75   
76       }
77       else if(ce.getActionType() == SetParameterXValueEvent.LIST_PARAM_XVALUE) {
78         // answer is the current parameter values: ParameterValues
79   
80         request.setAttribute
81           (WebKeys.SetParametersValues, "nolist");
82         // puts current parameter restrictions in the web request :
83         request.setAttribute(WebKeys.SetParameterXValueList, answer);
84   
85         HttpSession session = request.getSession();
86   
87         ParameterModel values = (ParameterModel)answer;
88         ArrayList point1 = values.getLevel1Point();
89         ArrayList point2 = values.getLevel2Point();
90   
91         // puts currents list of parameter of point 1 in the web session :
92         session.setAttribute(WebKeys.SetParmXValuePoint1, point1);
93   
94         // puts currents list of parameter of point 2 in the web session :
95         session.setAttribute(WebKeys.SetParmXValuePoint2, point2);
96   
97         nextScreen = "2";  // SETPARAMETERXVALUES_MAIN
98   
99       }
100      else if(ce.getActionType() == SetParameterXValueEvent.UPDATE_PARAM_XVALUE) {
101        // answer is an ParameterValues:
102        // 0: current parameter restrictions: ParameterValues
103        request.setAttribute
104          (WebKeys.SetParametersValues, "nolist");
105        // puts current parameter restrictions in the web request :
106        request.setAttribute
107          (WebKeys.SetParameterXValueList, answer);
108  
109        nextScreen = "2";  // SETPARAMETERXVALUES_MAIN
110  
111      }
112      else if(ce.getActionType() == SetParameterXValueEvent.VERIFY_PARAM_XVALUE) {
113        // answer is an ParameterValues:
114        // 0: current parameter restrictions: ParameterValues
115  
116        // puts current parameter restrictions in the web request :
117        request.setAttribute
118          (WebKeys.SetParameterXValueList, answer);
119  
120        nextScreen = "2";  // SETPARAMETERXVALUES_MAIN
121  
122      }
123      return nextScreen;
124    }
125  
126  
127    /**
128     * optional execution after processFlow method
129     *
130     * @param request Description of the Parameter
131     */
132    public void doEnd(HttpServletRequest request) { }
133  }
134  
135