1 63 64 package com.jcorporate.expresso.ext.taglib; 65 66 71 72 import com.jcorporate.expresso.core.controller.Block; 73 import com.jcorporate.expresso.core.controller.ControllerElement; 74 import org.apache.log4j.Logger; 75 76 import javax.servlet.jsp.JspTagException ; 77 import javax.servlet.jsp.tagext.Tag ; 78 import java.util.Enumeration ; 79 import java.util.Vector ; 80 81 82 111 public class ElementCollection 112 extends ExpressoTagSupport { 113 protected Enumeration elements = null; 114 private java.lang.String type = null; 115 private static Logger log = Logger.getLogger(ElementCollection.class); 116 117 public ElementCollection() { 118 super(); 119 } 120 121 public int doEndTag() 122 throws javax.servlet.jsp.JspTagException { 123 return EVAL_PAGE; 124 } 125 126 public int doStartTag() 127 throws javax.servlet.jsp.JspTagException { 128 getControllerResponse(); 129 130 Vector holding = null; 131 132 try { 133 BlockTag ancestorBlock = (BlockTag) getAncestor("com.jcorporate.expresso.ext.taglib.BlockTag"); 134 135 Tag cont = getContainer(); 136 ControllerElement container = null; 137 if (cont instanceof ElementIterator) { 138 container = ((ElementIterator) cont).getElement(); 139 } 140 141 if (container != null) { 142 if (getType().equalsIgnoreCase("block")) { 143 holding = ((Block) container).getBlocks(); 144 if (holding != null) { 145 elements = holding.elements(); 146 } 147 } else if (getType().equalsIgnoreCase("input")) { 148 holding = ((Block) container).getInputs(); 149 if (holding != null) { 150 elements = holding.elements(); 151 } 152 } else if (getType().equalsIgnoreCase("output")) { 153 holding = ((Block) container).getOutputs(); 154 if (holding != null) { 155 elements = holding.elements(); 156 } 157 } else if (getType().equalsIgnoreCase("transition")) { 158 holding = ((Block) container).getTransitions(); 159 if (holding != null) { 160 elements = holding.elements(); 161 } 162 163 } else if (getType().equalsIgnoreCase("nested")) { 164 holding = ((Block) container).getNested(); 167 if (holding != null) { 168 elements = holding.elements(); 169 } 170 } 171 } else if (ancestorBlock != null) { 172 Block block = ancestorBlock.getBlock(); 173 174 if (getType().equalsIgnoreCase("block")) { 175 holding = block.getBlocks(); 176 177 if (holding != null) { 178 elements = holding.elements(); 179 } 180 } else if (getType().equalsIgnoreCase("input")) { 181 holding = block.getInputs(); 182 183 if (holding != null) { 184 elements = holding.elements(); 185 } 186 } else if (getType().equalsIgnoreCase("output")) { 187 holding = block.getOutputs(); 188 189 if (holding != null) { 190 elements = holding.elements(); 191 } 192 } else if (getType().equalsIgnoreCase("transition")) { 193 holding = block.getTransitions(); 194 195 if (holding != null) { 196 elements = holding.elements(); 197 } 198 } else if (getType().equalsIgnoreCase("nested")) { 199 holding = block.getNested(); 202 if (holding != null) { 203 elements = holding.elements(); 204 } 205 } 206 } else { 207 if (getType().equalsIgnoreCase("block")) { 208 holding = ctlrResp.getBlocks(); 209 210 if (holding != null) { 211 elements = holding.elements(); 212 } 213 } else if (getType().equalsIgnoreCase("input")) { 214 holding = ctlrResp.getInputs(); 215 216 if (holding != null) { 217 elements = holding.elements(); 218 } 219 } else if (getType().equalsIgnoreCase("output")) { 220 holding = ctlrResp.getOutputs(); 221 222 if (holding != null) { 223 elements = holding.elements(); 224 } 225 } else if (getType().equalsIgnoreCase("transition")) { 226 holding = ctlrResp.getTransitions(); 227 228 if (holding != null) { 229 elements = holding.elements(); 230 } 231 } else if (getType().equalsIgnoreCase("nested")) { 232 holding = new Vector (); 238 Vector tmp = ctlrResp.getInputs(); 239 if (tmp == null) { 240 holding.addAll(tmp); 241 } 242 tmp = ctlrResp.getOutputs(); 243 if (tmp == null) { 244 holding.addAll(tmp); 245 } 246 tmp = ctlrResp.getTransitions(); 247 if (tmp == null) { 248 holding.addAll(tmp); 249 } 250 tmp = ctlrResp.getBlocks(); 251 if (tmp == null) { 252 holding.addAll(tmp); 253 } 254 elements = holding.elements(); 255 } 256 } 257 } catch (Exception e) { 258 log.error("Error from ElementCollection Tag:", e); 259 throw new JspTagException ("ElementCollection Tag Error: " + 260 e.getMessage()); 261 } 262 if (elements == null || !elements.hasMoreElements()) { 263 return SKIP_BODY; 264 } else { 265 return EVAL_BODY_INCLUDE; 266 } 267 } 268 269 protected Enumeration getElements() { 270 return elements; 271 } 272 273 public java.lang.String getType() { 274 return type; 275 } 276 277 public void setType(java.lang.String newType) { 278 type = newType; 279 } 280 281 } 282 283 284 | Popular Tags |