KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > enhydraManager > presentation > DetailPresentation


1 package enhydraManager.presentation;
2
3 import enhydraManager.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 host = null;
32     String JavaDoc appid = null;
33     String JavaDoc sesid = null;
34     String JavaDoc service = null;
35     try {
36         service = comms.request.getParameter("service");
37         host = comms.request.getParameter("host");
38         appid = comms.request.getParameter("appid");
39         sesid = comms.request.getParameter("sesid");
40     } catch (Exception JavaDoc e) {}
41        
42        
43     ApplicationSession applicationSession=ApplicationSessionFactory.getApplicationSession("enhydraManager.business.ApplicationSessionImpl");
44      Vector JavaDoc[] lists=applicationSession.getList(service,host,appid,sesid);
45  
46     Vector JavaDoc sessionAtributes = lists[0];
47     Vector JavaDoc sessionAttValues = lists[1];
48     
49     String JavaDoc sessionParam= null;
50     String JavaDoc sessionValue = null;
51             
52     detail = (DetailHTML)comms.xmlcFactory.create(DetailHTML.class);
53     
54     Node JavaDoc sessionElementRow = detail.getElementSessions_data_row();
55     Node JavaDoc no_entries_row = detail.getElementNo_entries_row();
56     Node JavaDoc sessions_data_row = detail.getElementSessions_data_row();
57     
58     detail.setTextSessionID(sesid + " Session List");
59     
60     if (sessionAtributes.size() == 0) {
61
62       sessions_data_row.getParentNode().removeChild(sessions_data_row);
63
64     }else if (sessionAtributes.size()==sessionAttValues.size()){
65         no_entries_row.getParentNode().removeChild(no_entries_row);
66         for (int i=0; i<sessionAtributes.size(); i++) {
67             
68             sessionParam= (String JavaDoc) sessionAtributes.elementAt(i);
69             sessionValue= (String JavaDoc) sessionAttValues.elementAt(i);
70             try {
71                 detail.setTextSessionParam(sessionParam);
72             } catch (IllegalArgumentException JavaDoc ex){
73                 detail.setTextSessionParam("Couldn't get Parameter Name!");
74             }
75             try {
76                 detail.setTextSessionValue(sessionValue);
77             } catch (IllegalArgumentException JavaDoc ex){
78                 detail.setTextSessionValue("Couldn't get Prameter Value!");
79             }
80             sessionElementRow.getParentNode().insertBefore(sessionElementRow.cloneNode(true),
81                                                                    sessionElementRow);
82         }
83         sessionElementRow.getParentNode().removeChild(sessionElementRow);
84     }
85     comms.response.writeDOM(detail);
86   }
87 }
88
89
Popular Tags