1 23 24 package org.dbforms.taglib; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import org.dbforms.util.KeyValuePair; 30 import org.dbforms.util.MessageResources; 31 import org.dbforms.util.Util; 32 33 import javax.servlet.jsp.JspException ; 34 35 36 37 43 public class StaticDataItem extends DbBaseHandlerTag 44 implements javax.servlet.jsp.tagext.TryCatchFinally { 45 private static Log logCat = LogFactory.getLog(StaticDataItem.class.getName()); private String key; 47 private String value; 48 49 54 public void setKey(String key) { 55 this.key = key; 56 } 57 58 59 64 public String getKey() { 65 return key; 66 } 67 68 69 74 public void setValue(String string) { 75 value = string; 76 } 77 78 79 84 public String getValue() { 85 String message = null; 86 87 if ((value != null) 88 && (getParent() instanceof StaticData 89 && getParent() 90 .getParent() instanceof DbBaseHandlerTag 91 && getParentForm() 92 .hasCaptionResourceSet())) { 93 try { 94 message = MessageResources.getMessage(value, getLocale()); 95 96 if (!Util.isNull(message)) { 97 value = message; 98 } 99 } catch (Exception e) { 100 logCat.debug("getValue(" + value + ") Exception : " 101 + e.getMessage()); 102 } 103 } 104 105 return value; 106 } 107 108 109 112 public void doCatch(Throwable t) throws Throwable { 113 throw t; 114 } 115 116 117 120 public void doFinally() { 121 key = null; 122 value = null; 123 super.doFinally(); 124 } 125 126 127 134 public int doStartTag() throws JspException { 135 if ((getParent() != null) 136 && getParent() instanceof StaticDataAddInterface) { 137 ((StaticDataAddInterface) getParent()).addElement(new KeyValuePair(key, 138 getValue())); 139 } else { 140 throw new JspException ("StaticDataItem element must be placed inside a AddStaticData element!"); 141 } 142 143 return EVAL_BODY_INCLUDE; 144 } 145 } 146 | Popular Tags |