KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sessionViewer > presentation > DetailPresentation


1 package sessionViewer.presentation;
2
3 import sessionViewer.spec.*;
4 // Standard imports
5
import java.util.Vector JavaDoc;
6 import java.io.IOException JavaDoc;
7
8 // Enhydra SuperServlet imports
9
import com.lutris.appserver.server.httpPresentation.HttpPresentation;
10 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
11 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
12 import org.w3c.dom.html.HTMLAnchorElement;
13 import org.w3c.dom.Node JavaDoc;
14
15 public class DetailPresentation implements HttpPresentation {
16
17   private static DetailHTML detail;
18
19   public void run(HttpPresentationComms comms) throws HttpPresentationException, IOException JavaDoc {
20
21     try{
22         OutputList(comms);
23     }catch(Exception JavaDoc e){
24       e.printStackTrace();
25     }
26   }
27
28
29   public static void OutputList(HttpPresentationComms comms) throws Exception JavaDoc {
30     
31     String JavaDoc appid = null;
32     String JavaDoc sesid = null;
33     try {
34         appid = comms.request.getParameter("appid");
35         sesid = comms.request.getParameter("sesid");
36     } catch (Exception JavaDoc e) {}
37        
38        
39     ApplicationSession applicationSession=ApplicationSessionFactory.getApplicationSession("sessionViewer.business.ApplicationSessionImpl");
40      Vector JavaDoc[] lists=applicationSession.getList(appid,sesid);
41  
42     Vector JavaDoc sessionAtributes = lists[0];
43     Vector JavaDoc sessionAttValues = lists[1];
44     
45     String JavaDoc sessionParam= null;
46     String JavaDoc sessionValue = null;
47             
48     detail = (DetailHTML)comms.xmlcFactory.create(DetailHTML.class);
49     
50     Node JavaDoc sessionElementRow = detail.getElementSessions_data_row();
51     Node JavaDoc no_entries_row = detail.getElementNo_entries_row();
52     Node JavaDoc sessions_data_row = detail.getElementSessions_data_row();
53     
54     detail.setTextSessionID(sesid + " Session List");
55     
56     if (sessionAtributes.size() == 0) {
57
58       sessions_data_row.getParentNode().removeChild(sessions_data_row);
59
60     }else if (sessionAtributes.size()==sessionAttValues.size()){
61         no_entries_row.getParentNode().removeChild(no_entries_row);
62         for (int i=0; i<sessionAtributes.size(); i++) {
63             
64             sessionParam= (String JavaDoc) sessionAtributes.elementAt(i);
65             sessionValue= (String JavaDoc) sessionAttValues.elementAt(i);
66             try {
67                 detail.setTextSessionParam(sessionParam);
68             } catch (IllegalArgumentException JavaDoc ex){
69                 detail.setTextSessionParam("Couldn't get Parameter Name!");
70             }
71             try {
72                 detail.setTextSessionValue(sessionValue);
73             } catch (IllegalArgumentException JavaDoc ex){
74                 detail.setTextSessionValue("Couldn't get Prameter Value!");
75             }
76             sessionElementRow.getParentNode().insertBefore(sessionElementRow.cloneNode(true),
77                                                                    sessionElementRow);
78         }
79         sessionElementRow.getParentNode().removeChild(sessionElementRow);
80     }
81     comms.response.writeDOM(detail);
82   }
83 }
84
85
Popular Tags