01: /*
02: * JivanExample
03: *
04: * Enhydra super-servlet presentation object
05: *
06: */
07:
08: package org.enhydra.jivan.test.presentation;
09:
10: // Enhydra SuperServlet imports
11: import com.lutris.appserver.server.httpPresentation.HttpPresentation;
12: import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
13: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
14: import java.util.*;
15: import org.enhydra.util.jivan.JivanSimpleXMLObjectImpl;
16:
17: import org.jivan.html.document.*;
18: import org.jivan.html.util.DOMUtil;
19: import org.jivan.apache.xerces.xni.parser.XMLInputSource;
20: import org.w3c.dom.html.HTMLAnchorElement;
21: import java.net.URL;
22: import com.lutris.logging.Logger;
23: import org.enhydra.jivan.test.JivanExample;
24:
25: import java.io.File;
26:
27: // Enhydra SuperServlet specification imports
28: import org.enhydra.jivan.test.spec.*;
29:
30: // Standard imports
31: import java.io.IOException;
32:
33: public class WelcomePresentation implements HttpPresentation {
34:
35: public void run(HttpPresentationComms comms)
36: throws HttpPresentationException {
37:
38: String protocol = "";
39: try {
40: protocol = JivanExample.rootPath
41: + File.separator
42: + comms.application.getConfig().getString(
43: "UserParameter.Jivan.ResourcesPath");
44: protocol = "file:///" + protocol + "/Welcome.html";
45:
46: //URL url = this.getClass().getClassLoader().getResource("org/enhydra/jivan/test/resources/Welcome.html");
47: //protocol = url.getProtocol() + "://" + url.getFile();
48:
49: //String protocol = System.getProperty("user.dir");
50: //protocol = "file:///" + protocol + "resources/Welcome.html";
51: } catch (Exception ex) {
52: ex.printStackTrace();
53: }
54:
55: comms.jivanFactory.getLogger().write(Logger.INFO,
56: "Loaded resources is: " + protocol); // logging
57: DocumentManager man = comms.jivanFactory.docManFor(protocol);
58:
59: String datetime;
60: try {
61: Dater dater = DaterFactory
62: .createDater("org.enhydra.jivan.test.business.DaterImpl");
63: datetime = dater.getDate();
64: } catch (Exception ex) {
65: System.out.println("Exception: " + ex);
66: datetime = "Could not get business object!!!";
67: }
68:
69: DOMUtil.setTextChild(man.lookup("time"), datetime);
70: HTMLAnchorElement link = (HTMLAnchorElement) man.lookup("link");
71: link.setHref("RedirectPresentation.po");
72:
73: JivanSimpleXMLObjectImpl xmlObject = new JivanSimpleXMLObjectImpl();
74: xmlObject.setDocument(man, "UTF-8");
75: comms.response.writeDOM(xmlObject);
76: }
77:
78: }
|