1 64 65 package com.jcorporate.expresso.ext.taglib; 66 67 import com.jcorporate.expresso.core.controller.ControllerElement; 68 69 import javax.servlet.jsp.JspTagException ; 70 import javax.servlet.jsp.JspWriter ; 71 72 73 99 public class AttributeTag 100 extends ExpressoTagSupport { 101 private java.lang.String controllerElement = null; 102 private java.lang.String name = null; 103 private java.lang.String type = null; 104 private java.lang.String controllerElementToUse = null; 105 private java.lang.String nameToUse = null; 106 private java.lang.String typeToUse = null; 107 private ControllerElement oneElement = null; 108 private String attributeContent = null; 109 110 public AttributeTag() { 111 super(); 112 } 113 114 public int doStartTag() throws javax.servlet.jsp.JspException { 115 controllerElementToUse = null; 116 nameToUse = null; 117 typeToUse = null; 118 oneElement = null; 119 attributeContent = null; 120 return SKIP_BODY; 121 } 122 123 124 129 public int doEndTag() 130 throws javax.servlet.jsp.JspTagException { 131 nameToUse = name; 132 typeToUse = type; 133 controllerElementToUse = controllerElement; 134 getControllerResponse(); 135 136 try { 137 138 if (type != null && !"".equals(type) && 140 controllerElementToUse != null && 141 !"".equals(controllerElementToUse)) { 142 if ("INPUT".equals(typeToUse)) { 143 oneElement = ctlrResp.getInput(controllerElementToUse); 144 } else { 145 oneElement = ctlrResp.getOutput(controllerElementToUse); 146 } 147 } 148 if (oneElement == null) { 149 150 InputTag ancestorInput = (InputTag) getAncestor( 153 com.jcorporate.expresso.ext.taglib.InputTag.class.getName()); 154 OutputTag ancestorOutput = (OutputTag) getAncestor( 155 com.jcorporate.expresso.ext.taglib.OutputTag.class.getName()); 156 boolean ancestorFoundFlag = false; 157 158 if (ancestorInput != null) { 159 ancestorFoundFlag = true; 160 typeToUse = "INPUT"; 161 } else if (ancestorOutput != null) { 162 ancestorFoundFlag = true; 163 typeToUse = "OUTPUT"; 164 } 165 if (ancestorFoundFlag) { 166 if ("INPUT".equals(typeToUse)) { 167 168 oneElement = ancestorInput.getInput(); 170 } else { 171 172 oneElement = ancestorOutput.getOutput(); 174 } 175 } 176 } 177 if (oneElement != null) { 178 attributeContent = oneElement.getAttribute(nameToUse); 179 } else { 180 attributeContent = "ATTRIBUTE NOT FOUND"; 181 } 182 183 JspWriter writer = pageContext.getOut(); 184 writer.print(attributeContent); 185 } catch (Exception e) { 186 throw new JspTagException ("AttributeTag Error: " + e.getMessage()); 187 } 188 189 return EVAL_PAGE; 190 } 191 192 193 199 public java.lang.String getControllerElement() { 200 return controllerElementToUse; 201 } 202 203 public java.lang.String getName() { 204 return nameToUse; 205 } 206 207 public java.lang.String getType() { 208 return typeToUse; 209 } 210 211 public void setControllerElement(java.lang.String newControllerElement) { 212 controllerElement = newControllerElement; 213 } 214 215 220 public void setName(java.lang.String newName) { 221 name = newName; 222 } 223 224 229 public void setType(java.lang.String newType) { 230 type = newType; 231 } 232 233 } | Popular Tags |