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.ServletContext;
11   import com.instantbank.common.utilcomponents.CodeDescription;
12   import com.instantbank.servicing.control.event.ParmSearchOrderEvent;
13   import com.instantbank.servicing.control.util.JSPUtil;
14   import com.instantbank.servicing.control.util.WebKeys;
15   import com.instantbank.common.utilcomponents.Debug;
16   import com.instantbank.common.utilcomponents.ServicingGlobals;
17   import com.instantbank.servicing.control.ServicingEventException;
18   
19   
20   /**
21    *  Set Parameter Search Order: flow handler for deciding output screen after
22    *  processing an action
23    *
24    * @author Instant-bank (Jorge Cardenas)
25    * @created September 2002
26    */
27   public class ParmSearchOrderFlowHandler
28       implements FlowHandler {
29     private Debug debug = null;
30   
31   
32     /**
33      *  optional execution before processFlow method
34      *
35      * @param request HTTP request
36      */
37     public void doStart(HttpServletRequest request) { }
38   
39   
40     /**
41      *  principal method for deciding output screen after processing an action
42      *
43      * @param request of MainServlet
44      * @param answer of the action
45      * @param context web context
46      * @return String with the number of the  output screen
47      * @exception ServicingEventException
48      */
49     public String processFlow(HttpServletRequest request, Object answer,
50                               ServletContext context)
51        throws ServicingEventException {
52   
53       debug = new Debug();
54       debug.setDebugginOn(true);
55       debug.setPreMessage("** ParmSearchOrderFlowHandler: ");
56       debug.println("processFlow");
57   
58       String nextScreen = null;
59       ParmSearchOrderEvent ce = null;
60   
61       if(request.getAttribute(WebKeys.ParmSearchOrderEvent) != null) {
62         ce = (ParmSearchOrderEvent)request.getAttribute(WebKeys.ParmSearchOrderEvent);
63       }
64   
65       if(request.getAttribute(WebKeys.ExceptionOcurred) != null) {
66         nextScreen = "1";  // PARMSEARCHORDER_PROBLEM
67   
68       }
69       else if(ce.getActionType() == ParmSearchOrderEvent.LIST_PARM_SEARCH_ORDER) {
70         // answer is the current parameter search order: ArrayList()
71         // puts current parameter search order  in the web request :
72   
73         request.setAttribute(WebKeys.ParmSearchOrderList, answer);
74         nextScreen = "2";  // PARMSEARCHORDER_MAIN
75   
76       }
77       else if(ce.getActionType() == ParmSearchOrderEvent.UPDATE_PARM_SEARCH_ORDER) {
78         // answer is an ArrayList with 2 elements:
79         // 0: possible problem: String
80         // 1: current parameter search order: ArrayList()
81   
82         // puts current parameter search order in the web request :
83         request.setAttribute
84           (WebKeys.ParmSearchOrderList, ((ArrayList)answer).get(1));
85   
86         String problem = (String)(((ArrayList)answer).get(0));
87         if(problem.equals(ServicingGlobals.STR_UNDEF)) {
88           nextScreen = "2";  // PARMSEARCHORDER_MAIN
89         }
90         else {  // problem is: theProblem|theStackTrace
91           JSPUtil.putProblemInRequest(request, problem);
92           nextScreen = "1";  // PARMSEARCHORDER_PROBLEM
93         }
94       }
95       return nextScreen;
96     }
97   
98   
99     /**
100     * optional execution after processFlow method
101     *
102     * @param request Description of the Parameter
103     */
104    public void doEnd(HttpServletRequest request) { }
105  }
106  
107