KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > enhydraManager > presentation > ApplicationPresentation


1 package enhydraManager.presentation;
2
3
4 import enhydraManager.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    String JavaDoc host = null;
34     String JavaDoc service = null;
35     try {
36         
37         service = comms.request.getParameter("service");
38         host = comms.request.getParameter("host");
39         id = comms.request.getParameter("id");
40     } catch (Exception JavaDoc e) {}
41        
42       
43      ApplicationSessionList applicationSessionList=ApplicationSessionListFactory.getApplicationSessionList("enhydraManager.business.ApplicationSessionListImpl");
44      Vector JavaDoc sessionList=applicationSessionList.getList(service,host,id);
45      
46
47     
48     String JavaDoc sessionID= null;
49             
50     application = (ApplicationHTML)comms.xmlcFactory.create(ApplicationHTML.class);
51     
52     Node JavaDoc sessionElementRow = application.getElementSessions_row();
53     Node JavaDoc no_entries_row = application.getElementNo_entries_row();
54     Node JavaDoc sessions_row = application.getElementSessions_row();
55     
56     application.setTextAppName(id.substring(1) + " Session List");
57     
58     if (sessionList.size() == 0) {
59
60       sessions_row.getParentNode().removeChild(sessions_row);
61
62     }else {
63         no_entries_row.getParentNode().removeChild(no_entries_row);
64         for (int i=0; i<sessionList.size(); i++) {
65             
66             sessionID = (String JavaDoc) sessionList.elementAt(i);
67             
68             HTMLAnchorElement anchorView = application.getElementView();
69             anchorView.setHref("DetailPresentation.po?service="+service+"&host="+host+"&appid="+id+"&sesid="+ sessionID);
70             anchorView.setTitle("Click to view Application session in more detail!");
71             try {
72                 application.setTextView(sessionID);
73             } catch (IllegalArgumentException JavaDoc ex){
74                 application.setTextView("Couldn't get SessionID!");
75             }
76             sessionElementRow.getParentNode().insertBefore(sessionElementRow.cloneNode(true),
77                                                                    sessionElementRow);
78             
79         }
80         sessionElementRow.getParentNode().removeChild(sessionElementRow);
81     }
82     comms.response.writeDOM(application);
83   }
84 }
85
86
Popular Tags