KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jivan > test > presentation > WelcomePresentation


1 /*
2  * JivanExample
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package org.enhydra.jivan.test.presentation;
9
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 JavaDoc;
22 import com.lutris.logging.Logger;
23 import org.enhydra.jivan.test.JivanExample;
24
25 import java.io.File JavaDoc;
26
27 // Enhydra SuperServlet specification imports
28
import org.enhydra.jivan.test.spec.*;
29
30 // Standard imports
31
import java.io.IOException JavaDoc;
32
33 public class WelcomePresentation implements HttpPresentation {
34
35
36     public void run(HttpPresentationComms comms)
37         throws HttpPresentationException {
38
39       String JavaDoc protocol = "";
40       try {
41         protocol = JivanExample.rootPath + File.separator + comms.application.getConfig().getString("UserParameter.Jivan.ResourcesPath");
42         protocol = "file:///" + protocol + "/Welcome.html";
43         
44         //URL url = this.getClass().getClassLoader().getResource("org/enhydra/jivan/test/resources/Welcome.html");
45
//protocol = url.getProtocol() + "://" + url.getFile();
46

47         //String protocol = System.getProperty("user.dir");
48
//protocol = "file:///" + protocol + "resources/Welcome.html";
49
}
50       catch(Exception JavaDoc ex) {
51         ex.printStackTrace();
52       }
53
54       comms.jivanFactory.getLogger().write(Logger.INFO, "Loaded resources is: " + protocol); // logging
55
DocumentManager man = comms.jivanFactory.docManFor(protocol);
56
57       String JavaDoc datetime;
58         try {
59           Dater dater = DaterFactory.createDater("org.enhydra.jivan.test.business.DaterImpl");
60           datetime = dater.getDate();
61         }
62         catch (Exception JavaDoc ex){
63             System.out.println("Exception: "+ex);
64             datetime="Could not get business object!!!";
65         }
66
67       DOMUtil.setTextChild(man.lookup("time"), datetime);
68       HTMLAnchorElement link = (HTMLAnchorElement) man.lookup("link");
69       link.setHref("RedirectPresentation.po");
70
71       JivanSimpleXMLObjectImpl xmlObject = new JivanSimpleXMLObjectImpl();
72       xmlObject.setDocument(man, "UTF-8");
73       comms.response.writeDOM(xmlObject);
74     }
75
76 }
77
Popular Tags