01: /*
02: * tableAppClient
03: *
04: * Enhydra super-servlet presentation object
05: *
06: * Prozone
07: *
08: */
09:
10: package tableappclient.presentation;
11:
12: // Enhydra SuperServlet imports
13: import com.lutris.appserver.server.httpPresentation.HttpPresentation;
14: import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
15: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
16:
17: import org.w3c.dom.Node;
18: import org.w3c.dom.Element;
19: import org.w3c.dom.html.HTMLTableElement;
20: import org.w3c.dom.html.HTMLTableRowElement;
21: import org.w3c.dom.html.HTMLElement;
22:
23: // Enhydra SuperServlet specification imports
24: import tableappclient.spec.*;
25:
26: // Standard imports
27: import java.io.IOException;
28:
29: public class WelcomePresentation implements HttpPresentation {
30: static final String FOUND = "The following table has been retrieved from the TableApp application and transferred in a Document object, via Axis/Soap:";
31: static final String NOTFOUND = "The server application TableApp has not been accessed yet. Access and refresh it few times, then refresh this window.";
32: static final String FOUNDOBJ = "The following data have been retrieved from the TableApp application and transferred in a custom serialized object, via Axis/Soap:";
33: static final String NOTFOUNDOBJ = "The following data will be retrieved from the TableApp application and transferred in a custom serialized object, via Axis/Soap:";
34:
35: public void run(HttpPresentationComms comms)
36: throws HttpPresentationException, IOException {
37: String server = null;
38: try {
39: server = comms.request.getServerName();
40: } catch (Exception e) {
41: }
42: String port = null;
43: try {
44: port = new Integer(comms.request.getServerPort())
45: .toString();
46: } catch (Exception e) {
47: }
48:
49: String text = "1";
50: String textObj = "2";
51: WelcomeHTML welcome = (WelcomeHTML) comms.xmlcFactory
52: .create(WelcomeHTML.class);
53: try {
54: TableNode tableNode = TableNodeFactory
55: .createTableNode("tableappclient.business.TableNodeImpl");
56: AccessData accessData = AccessDataFactory.createAccessData(
57: "tableappclient.business.AccessDataImpl", server,
58: port);
59: Node node = tableNode.getTableNode(server, port);
60: if (node == null) {
61: text = NOTFOUND;
62: textObj = NOTFOUNDOBJ;
63: } else {
64: text = FOUND;
65: textObj = FOUNDOBJ;
66: HTMLTableElement welcomeTable = welcome
67: .getElementTemplateTable();
68: Node welcomeNode = welcome.importNode(node, true);
69: Node parentNode = welcomeTable.getParentNode();
70: parentNode.appendChild(welcomeNode);
71: HTMLTableRowElement templateRow = welcome
72: .getElementTemplateRow();
73: HTMLElement noAccessesElement = welcome
74: .getElementAccNum();
75: HTMLElement timeElement = welcome.getElementAccTime();
76: templateRow.removeAttribute("id");
77: noAccessesElement.removeAttribute("id");
78: timeElement.removeAttribute("id");
79: Node parrent = templateRow.getParentNode();
80: welcome.setTextAccNum(new Integer(accessData
81: .getNoAccesses()).toString());
82: welcome.setTextAccTime(accessData.getAccessTime());
83: parrent.appendChild(templateRow.cloneNode(true));
84: parrent.removeChild(templateRow);
85: }
86: } catch (Exception ex) {
87: System.out.println("Exception: " + ex);
88: text = "Could not get business object!!!";
89: }
90: welcome.setTextObjectTextTemplate(textObj);
91: welcome.setTextTextTemplate(text);
92: comms.response.writeDOM(welcome);
93: }
94: }
|