1 package com.instantbank.lettertemplate.control.ejb.handlers;
2
3 import java.util.ArrayList;
4 import java.rmi.RemoteException;
5 import javax.naming.InitialContext;
6 import javax.naming.NamingException;
7 import javax.ejb.CreateException;
8 import javax.ejb.DuplicateKeyException;
9 import javax.ejb.FinderException;
10
11 import com.instantbank.common.utilcomponents.JNDINames;
12 import com.instantbank.common.utilcomponents.Debug;
13 import com.instantbank.lettertemplate.control.event.PreviewPrintEvent;
14 import com.instantbank.component.lettertemplate.ejb.LetterTemplate;
15 import com.instantbank.lettertemplate.control.LetterTemplateEventException;
16 import com.instantbank.lettertemplate.control.event.LetterTemplateEvent;
17
18
24 public class PreviewPrintHandler extends StateHandlerSupport {
25
26 private Debug debug = null;
27
28
29
36 public Object perform(LetterTemplateEvent event)
37 throws LetterTemplateEventException {
38 debug = new Debug();
39 debug.setDebugginOn(true);
40 debug.setPreMessage("**PreviewPrintEvent-services tier: ");
41
42 Object answer = "";
43 PreviewPrintEvent ce = (PreviewPrintEvent)event;
44
45 switch (ce.getActionType()) {
46
47 case PreviewPrintEvent.LIST_TEMPLATES_PREVIEW:
48 {
49 debug.println(" LIST TEMPLATES event");
50 try {
51 LetterTemplate letterTemplate
52 = machine.getLetterTemplateControllerEJB()
53 .getLetterTemplate
54 (ce.getCompanyId(), ce.getUserId());
55
56
57 ArrayList listTemplates
58 = letterTemplate.loadAllTemplatesDescription();
59
60 answer = listTemplates;
61 }
62 catch(Exception e) {
63 throw new LetterTemplateEventException(e.getMessage());
64 }
65
66 }
67 break;
68 default:
69 debug.println("Error: not implemented yet");
70 break;
71 }
72 return answer;
73 }
74 }
75
76