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 47 public class ApplyGlossaryTag extends TagSupport { 48 49 private String value = ""; 50 51 private String id = ""; 52 53 JspWriter out; 54 55 58 public void setValue(String v) { 59 value = v; 60 } 61 62 65 public String getValue() { 66 return (value); 67 } 68 69 72 public void setId(String v) { 73 id = v; 74 } 75 76 79 public String getId() { 80 return id; 81 } 82 83 87 public int doStartTag() throws JspException { 88 89 boolean emptyValue = false; 90 ServletRequest req = pageContext.getRequest(); 92 CofaxPage cofaxPage = (CofaxPage) req.getAttribute("cofaxPage"); 93 94 String newValue = cofaxPage.applyGlossary(value); 95 if (newValue != null) { 96 pageContext.setAttribute(getId(), newValue); 97 } else { 98 emptyValue = true; 99 } 100 101 PackageTag parent = (PackageTag) findAncestorWithClass(this, PackageTag.class); 103 out = pageContext.getOut(); 104 if (parent != null) { 105 HashMap currentRow = parent.getRowData(); 106 if (currentRow != null) { 107 newValue = CofaxPage.applyGlossaryWithHashMap(value, currentRow); 108 if (newValue != null) { 109 pageContext.setAttribute(getId(), newValue); 110 } else { 111 emptyValue = true; 112 } 113 } 114 } 116 if (emptyValue) { 117 pageContext.setAttribute(getId(), ""); 118 } 119 120 return SKIP_BODY; 121 } 122 123 126 public int doEndTag() throws JspException { 127 return EVAL_PAGE; 128 } 129 130 133 public void printMessage(String message) throws JspException { 134 135 try { 136 out.print(message); 137 } catch (Exception ex) { 138 throw new JspException("IO problems printMessage() " + ex); 139 } 140 return; 141 } 142 143 } 145 | Popular Tags |