KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > tutorials > comp > HelloWorld1a


1 package org.enhydra.barracuda.tutorials.comp;
2
3 import java.io.*;
4 import java.util.*;
5 import javax.servlet.*;
6 import javax.servlet.http.*;
7
8 import org.w3c.dom.*;
9 import org.enhydra.xml.xmlc.*;
10
11 import org.enhydra.barracuda.core.comp.*;
12 import org.enhydra.barracuda.core.comp.helper.*;
13 import org.enhydra.barracuda.core.util.dom.*;
14 import org.enhydra.barracuda.tutorials.xmlc.*;
15
16 /**
17  * Here's an example of HelloWorld using the BTemplate
18  * component
19  */

20 public class HelloWorld1a extends ComponentGateway {
21
22     //xmlc factory (ok as static because its threadsafe)
23
// private static XMLCFactory xmlcFactory = null;
24

25     //-------------------- ComponentGateway ----------------------
26
/**
27      * Handle the default HttpRequest.
28      */

29     public Document handleDefault (BComponent root, ViewContext vc, HttpServletRequest req, HttpServletResponse resp) throws IOException {
30         //load the DOM object and find the target node
31
// if (xmlcFactory==null) xmlcFactory = new XMLCStdFactory(this.getClass().getClassLoader(), new StreamXMLCLogger());
32
// XMLObject page = xmlcFactory.create(HelloWorld1HTML.class);
33

34         //load the localized DOM template
35
Document page = DefaultDOMLoader.getGlobalInstance().getDOM(HelloWorld1HTML.class, vc.getViewCapabilities().getClientLocale());
36         Node node = page.getElementById("HelloWorld");
37
38         //create the component and bind it to the view and the model
39
BTemplate templateComp = new BTemplate(new DefaultPropertiesModel("org.enhydra.barracuda.tutorials.comp.HelloWorld"));
40         templateComp.setView(new DefaultTemplateView(node));
41
42         //add the component to the root
43
root.addChild(templateComp);
44     
45         //return the page
46
return page;
47     }
48 }
49
Popular Tags