1    package com.instantbank.lettertemplate.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   
12   import javax.servlet.http.HttpServletRequest;
13   import javax.servlet.ServletContext;
14   import javax.servlet.http.HttpSession;
15   import com.instantbank.lettertemplate.control.event.BatchReviewEvent;
16   import com.instantbank.lettertemplate.control.util.JSPUtil;
17   import com.instantbank.lettertemplate.control.util.WebKeys;
18   import com.instantbank.common.utilcomponents.Debug;
19   import com.instantbank.common.utilcomponents.CommonUtil;
20   import com.instantbank.lettertemplate.control.LetterTemplateEventException;
21   import com.instantbank.component.lettertemplate.util.*;
22   
23   /**
24    *  Letter Batch Review usecase: flow handler for deciding output screen after
25    *  processing an action
26    *
27    * @author Instant-bank (Jorge Cardenas)
28    * @created November 2002
29    */
30   public class BatchReviewFlowHandler
31       implements FlowHandler {
32     private Debug debug = null;
33   
34   
35     /**
36      *  optional execution before processFlow method
37      *
38      * @param request HTTP request
39      */
40     public void doStart(HttpServletRequest request) { }
41   
42   
43     /**
44      *  principal method for deciding output screen after processing an action
45      *
46      * @param request of MainServlet
47      * @param answer of the action
48      * @param context web context
49      * @return String with the number of the output screen
50      * @throws LetterTemplateEventException Description of the Exception
51      */
52     public String processFlow(HttpServletRequest request, Object answer,
53                               ServletContext context)
54        throws LetterTemplateEventException {
55   
56       debug = new Debug();
57       debug.setDebugginOn(true);
58       debug.setPreMessage("** BatchReviewFlowHandler: ");
59       debug.println("processFlow");
60   
61       String nextScreen = null;
62       BatchReviewEvent ce = null;
63       HttpSession session = request.getSession();
64   
65       if(request.getAttribute(WebKeys.BatchReviewEvent) != null) {
66         ce = (BatchReviewEvent)request.getAttribute(WebKeys.BatchReviewEvent);
67       }
68   
69       if(request.getAttribute(WebKeys.ExceptionOcurred) != null) {
70   
71         nextScreen = "1";  // BATCHREVIEW_PROBLEM
72   
73       }
74       else if(ce.getActionType() == BatchReviewEvent.LIST_BATCH_REVIEW) {
75         // answer is the current letters batch review.
76         // puts current letters batch in the web request :
77   
78         request.setAttribute(WebKeys.BatchReviewList, answer);
79   
80         nextScreen = "2";  //  BATCHREVIEW_MAIN
81   
82       }
83       else if(ce.getActionType() == BatchReviewEvent.UPDATE_BATCH_REVIEW) {
84         // answer is the current letters batch review.
85         // puts current letters batch in the web request :
86   
87         request.setAttribute(WebKeys.BatchReviewList, answer);
88         nextScreen = "2";  //  BATCHREVIEW_MAIN
89   
90       }
91       return nextScreen;
92     }
93   
94   
95     /**
96      * optional execution after processFlow method
97      *
98      * @param request Description of the Parameter
99      */
100    public void doEnd(HttpServletRequest request) { }
101  }
102  
103