1 22 23 package org.cofax.taglibs; 24 25 import javax.servlet.*; 26 import javax.servlet.jsp.*; 27 import javax.servlet.jsp.tagext.*; 28 import java.util.*; 29 import org.cofax.*; 30 31 37 public class PrintTag extends TagSupport { 38 39 private String name = ""; 40 41 JspWriter out; 42 43 46 public void setName(String v) { 47 name = v; 48 } 49 50 53 public String getName() { 54 return (name); 55 } 56 57 60 public int doStartTag() throws JspException { 61 62 PackageTag parent = (PackageTag) findAncestorWithClass(this, PackageTag.class); 63 out = pageContext.getOut(); 64 65 while (parent != null) { 66 67 if (parent.fieldExists(name)) { 68 printMessage(parent.getField(name)); 69 70 return (SKIP_BODY); 71 } 72 73 parent = (PackageTag) findAncestorWithClass(parent, PackageTag.class); 74 } 76 ServletRequest req = pageContext.getRequest(); 77 CofaxPage cofaxPage = (CofaxPage) req.getAttribute("cofaxPage"); 78 79 HashMap glossary = cofaxPage.getGlossary().getKeyValues(); 80 81 if (glossary.containsKey(name)) { 82 83 printMessage(glossary.get(name).toString()); 84 85 } else { 86 87 printMessage(""); 88 } 89 90 return SKIP_BODY; 91 } 92 93 96 public int doEndTag() throws JspException { 97 return EVAL_PAGE; 98 } 99 100 103 public void printMessage(String message) throws JspException { 104 try { 105 out.print(message); 106 } catch (Exception ex) { 107 throw new JspException("IO problems printMessage() " + ex); 108 } 109 return; 110 } 111 112 } 114 | Popular Tags |