1 64 65 package com.jcorporate.expresso.ext.taglib; 66 67 import com.jcorporate.expresso.core.controller.Block; 68 69 import javax.servlet.jsp.JspTagException ; 70 import javax.servlet.jsp.JspWriter ; 71 import javax.servlet.jsp.tagext.Tag ; 72 73 74 77 public class BlockTag 78 extends ExpressoTagSupport { 79 80 protected Block oneBlock = null; 82 83 protected java.lang.String name = null; 85 protected java.lang.String nameToUse = null; 86 87 public BlockTag() { 88 super(); 89 } 90 91 public int doEndTag() 92 throws javax.servlet.jsp.JspTagException { 93 return EVAL_PAGE; 94 } 95 96 public int doStartTag() 97 throws javax.servlet.jsp.JspTagException { 98 nameToUse = name; 99 getControllerResponse(); 100 101 try { 102 Tag container = getContainer(); 103 104 if (container == null) { 105 oneBlock = ctlrResp.getBlock(nameToUse); 106 } else { 107 if (container instanceof ElementIterator) { 108 oneBlock = (Block) ((ElementIterator) container).getElement(); 109 nameToUse = oneBlock.getName(); 110 } else if (container instanceof BlockTag) { 111 oneBlock = (Block) ((BlockTag) container).getBlock().getContent(getName()); 112 } else { 113 throw new JspTagException ("ActionTag: cannot handle container tag" + 114 container.getClass().getName()); 115 } 116 } 117 118 JspWriter writer = pageContext.getOut(); 119 120 if (oneBlock == null) { 121 writer.println("The Block Named " + nameToUse + 122 " Could Not Be Found"); 123 } 124 } catch (Exception e) { 125 throw new JspTagException ("Block Tag Error: " + e.getMessage()); 126 } 127 128 return EVAL_BODY_INCLUDE; 129 } 130 131 public Block getBlock() { 132 return oneBlock; 133 } 134 135 public java.lang.String getName() { 136 return nameToUse; 137 } 138 139 public void setName(java.lang.String newName) { 140 name = newName; 141 } 142 } 143 144 | Popular Tags |