KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sessionViewer > presentation > ApplicationPresentation


1 package sessionViewer.presentation;
2
3
4 import sessionViewer.spec.*;
5 // Standard imports
6
import java.util.Vector JavaDoc;
7 import java.io.IOException JavaDoc;
8
9 // Enhydra SuperServlet imports
10
import com.lutris.appserver.server.httpPresentation.HttpPresentation;
11 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
12 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
13 import org.w3c.dom.html.HTMLAnchorElement;
14 import org.w3c.dom.Node JavaDoc;
15
16 public class ApplicationPresentation implements HttpPresentation {
17
18   private static ApplicationHTML application;
19
20   public void run(HttpPresentationComms comms) throws HttpPresentationException, IOException JavaDoc {
21
22     try{
23         OutputList(comms);
24     }catch(Exception JavaDoc e){
25       e.printStackTrace();
26     }
27   }
28
29
30   public static void OutputList(HttpPresentationComms comms) throws Exception JavaDoc {
31     
32     String JavaDoc id = null;
33     try {
34         id = comms.request.getParameter("id");
35     } catch (Exception JavaDoc e) {}
36        
37       
38      ApplicationSessionList applicationSessionList=ApplicationSessionListFactory.getApplicationSessionList("sessionViewer.business.ApplicationSessionListImpl");
39      Vector JavaDoc sessionList=applicationSessionList.getList(id);
40      
41
42     
43     String JavaDoc sessionID= null;
44             
45     application = (ApplicationHTML)comms.xmlcFactory.create(ApplicationHTML.class);
46     
47     Node JavaDoc sessionElementRow = application.getElementSessions_row();
48     Node JavaDoc no_entries_row = application.getElementNo_entries_row();
49     Node JavaDoc sessions_row = application.getElementSessions_row();
50     
51     application.setTextAppName(id.substring(1) + " Session List");
52     
53     if (sessionList.size() == 0) {
54
55       sessions_row.getParentNode().removeChild(sessions_row);
56
57     }else {
58         no_entries_row.getParentNode().removeChild(no_entries_row);
59         for (int i=0; i<sessionList.size(); i++) {
60             
61             sessionID = (String JavaDoc) sessionList.elementAt(i);
62             
63             HTMLAnchorElement anchorView = application.getElementView();
64             anchorView.setHref("DetailPresentation.po?appid="+id+"&sesid="+ sessionID);
65             anchorView.setTitle("Click to view Application session in more detail!");
66             try {
67                 application.setTextView(sessionID);
68             } catch (IllegalArgumentException JavaDoc ex){
69                 application.setTextView("Couldn't get SessionID!");
70             }
71             sessionElementRow.getParentNode().insertBefore(sessionElementRow.cloneNode(true),
72                                                                    sessionElementRow);
73             
74         }
75         sessionElementRow.getParentNode().removeChild(sessionElementRow);
76     }
77     comms.response.writeDOM(application);
78   }
79 }
80
81
Popular Tags