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 24 public class CompEx7 extends ComponentGateway { 25 26 30 public Document handleDefault (BComponent root, ViewContext vc, HttpServletRequest req, HttpServletResponse resp) throws IOException { 31 Document page = DefaultDOMLoader.getGlobalInstance().getDOM(CompEx7HTML.class); 33 34 BTemplate templateComp = new BTemplate(new LocalTemplateModel(req)); 36 templateComp.setView(new DefaultTemplateView(page.getDocumentElement())); 37 root.addChild(templateComp); 38 39 return page; 41 } 42 43 49 public DOMWriter getDOMWriter() { 50 return new DefaultDOMWriter(true); 52 } 53 54 58 class LocalTemplateModel extends AbstractTemplateModel { 59 60 HttpServletRequest req = null; 61 62 public LocalTemplateModel(HttpServletRequest ireq) { 63 req = ireq; 64 } 65 66 public String getName() {return "Test1";} 68 69 public Object getItem(String key) { 71 ViewContext vc = getViewContext(); 72 ViewCapabilities vcap = vc.getViewCapabilities(); 73 if (key.equals("NormalText1")) { 74 return "Text1: <strong>bold</strong>"; 75 } else if (key.equals("NormalText2")) { 76 return new BLink("Link1: A link with <em>zing1</em>", "blah99.html"); 77 } else if (key.equals("MarkupText1")) { 78 BText btext = new BText("Text2: <strong>bold</strong>"); 79 btext.setAllowMarkupInText(true); 80 return btext; 81 } else if (key.equals("MarkupText2")) { 82 BLink blink = new BLink("Link2: A link with <em>zing2</em>", "blah99.html"); 83 blink.setAllowMarkupInText(true); 84 return blink; 85 } else { 86 return super.getItem(key); 87 } 88 } 89 } 90 } 91 | Popular Tags |