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 45 public class ValueTag extends TagSupport { 46 47 private String name = ""; 48 49 private String id = ""; 50 51 JspWriter out; 52 53 56 public void setName(String v) { 57 name = v; 58 } 59 60 63 public String getName() { 64 return (name); 65 } 66 67 70 public void setId(String v) { 71 id = v; 72 } 73 74 77 public String getId() { 78 return id; 79 } 80 81 84 public int doStartTag() throws JspException { 85 86 PackageTag parent = (PackageTag) findAncestorWithClass(this, PackageTag.class); 87 out = pageContext.getOut(); 88 89 while (parent != null) { 90 91 if (parent.fieldExists(name)) { 92 93 pageContext.setAttribute(getId(), parent.getField(name)); 94 return (SKIP_BODY); 95 } 96 97 parent = (PackageTag) findAncestorWithClass(parent, PackageTag.class); 98 } 100 ServletRequest req = pageContext.getRequest(); 101 CofaxPage cofaxPage = (CofaxPage) req.getAttribute("cofaxPage"); 102 HashMap glossary = cofaxPage.getGlossary().getKeyValues(); 103 104 if (glossary.containsKey(name)) { 105 106 pageContext.setAttribute(getId(), glossary.get(name)); 107 108 } else { 109 pageContext.setAttribute(getId(), ""); 110 } 111 112 return SKIP_BODY; 113 } 114 115 118 public int doEndTag() throws JspException { 119 return EVAL_PAGE; 120 } 121 122 125 public void printMessage(String message) throws JspException { 126 127 try { 128 out.print(message); 129 } catch (Exception ex) { 130 throw new JspException("IO problems printMessage() " + ex); 131 } 132 return; 133 } 134 135 } 137 | Popular Tags |