1 64 65 package com.jcorporate.expresso.ext.taglib; 66 67 import com.jcorporate.expresso.core.controller.Output; 68 69 import javax.servlet.jsp.JspTagException ; 70 import javax.servlet.jsp.JspWriter ; 71 import javax.servlet.jsp.tagext.Tag ; 72 73 74 94 public class OutputTag 95 extends ExpressoTagSupport { 96 private Output oneOutput = null; 97 private java.lang.String name = null; 98 private java.lang.String content = null; 99 private java.lang.String nameToUse = null; 100 private java.lang.String contentToUse = null; 101 102 public OutputTag() { 103 super(); 104 } 105 106 111 public int doEndTag() 112 throws javax.servlet.jsp.JspTagException { 113 return EVAL_PAGE; 114 } 115 116 117 124 public int doStartTag() 125 throws javax.servlet.jsp.JspTagException { 126 nameToUse = name; 127 contentToUse = content; 128 getControllerResponse(); 129 130 try { 131 Tag container = getContainer(); 132 133 if (container == null) { 134 oneOutput = ctlrResp.getOutput(name); 135 } else { 136 if (container instanceof ElementIterator) { 137 oneOutput = (Output) ((ElementIterator) container).getElement(); 138 nameToUse = oneOutput.getName(); 139 } else if (container instanceof BlockTag) { 140 oneOutput = (Output) ((BlockTag) container).getBlock().getContent(getName()); 141 } else if (container instanceof OutputTag) { 142 oneOutput = (Output) ((OutputTag) container).getOutput().getNested(name); 143 } else { 144 throw new JspTagException ("OutputTag: cannot handle container tag" + 145 container.getClass().getName()); 146 } 147 } 148 149 JspWriter writer = pageContext.getOut(); 150 151 if (oneOutput == null) { 152 writer.println("The Output Named " + nameToUse + 153 " Could Not Be Displayed"); 154 } else { 155 156 contentToUse = oneOutput.getContent(); 158 } 159 } catch (Exception e) { 160 throw new JspTagException ("OutputTag Error: " + e.getMessage()); 161 } 162 163 return EVAL_BODY_INCLUDE; 164 } 165 166 167 public java.lang.String getContent() { 168 return contentToUse; 169 } 170 171 public java.lang.String getName() { 172 return nameToUse; 173 } 174 175 public Output getOutput() { 176 return oneOutput; 177 } 178 179 184 public void setContent(java.lang.String newContent) { 185 content = newContent; 186 } 187 188 191 public void setName(java.lang.String newName) { 192 name = newName; 193 } 194 } | Popular Tags |