KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > examples > xmlc > CompEx8


1 package org.enhydra.barracuda.examples.xmlc;
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.w3c.dom.html.*;
10 import org.enhydra.xml.xmlc.*;
11
12 import org.enhydra.barracuda.core.comp.*;
13 import org.enhydra.barracuda.core.comp.helper.*;
14 import org.enhydra.barracuda.core.util.dom.*;
15 import org.enhydra.barracuda.core.event.*;
16 import org.enhydra.barracuda.core.util.dom.*;
17 import org.enhydra.barracuda.core.view.*;
18 import org.enhydra.barracuda.examples.xmlc.data.*;
19
20 /**
21  * Test our ability to detect client side Javascript being
22  * enabled.
23  */

24 public class CompEx8 extends BTemplateGateway {
25
26     
27
28     //-------------------- BTemplateGateway ----------------------
29
/**
30      * Return an instance of the template model
31      */

32     public TemplateModel getTemplateModel() {
33         return new LocalTemplateModel();
34     }
35     
36     /**
37      * Return an instance of the template class (must implement Document)
38      */

39     public Class JavaDoc getTemplateClass() {
40         return CompEx8HTML.class;
41     }
42     
43     public DOMWriter getDOMWriter() {
44         return new DefaultDOMWriter(true);
45     }
46
47     //--------------- TemplateModel --------------------------
48
/**
49      * LocalTemplateModel
50      */

51     class LocalTemplateModel extends AbstractTemplateModel {
52     
53         //register the model by name
54
public String JavaDoc getName() {return "Ex8";}
55         
56         //provide items by key
57
public Object JavaDoc getItem(String JavaDoc key) {
58             ViewContext vc = getViewContext();
59             ViewCapabilities vcap = vc.getViewCapabilities();
60             if (key.equals("Link1")) {
61                 return new BLink("A sample link", "/Barracuda/CompTest8");
62             } else if (key.equals("Form1")) {
63                 return new BAction("/Barracuda/CompTest8");
64             } else {
65                 return super.getItem(key);
66             }
67         }
68     }
69 }
70
Popular Tags