1 package com.sslexplorer.core.tags; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletException ; 6 import javax.servlet.jsp.JspException ; 7 import javax.servlet.jsp.tagext.BodyTagSupport ; 8 9 import org.apache.struts.taglib.TagUtils; 10 import org.apache.struts.tiles.TilesUtil; 11 12 16 public class BlankActionTag extends BodyTagSupport { 17 18 private boolean blank = false; 19 private int tiles = 1; 20 21 26 public int doAfterBody() throws JspException { 27 28 if (bodyContent != null) { 29 String value = bodyContent.getString().trim(); 30 if (value.length() == 0) { 31 blank = true; 32 } 33 else 34 { 35 blank = false; 36 } 37 } 38 return (EVAL_BODY_INCLUDE); 39 40 } 41 42 public int doEndTag() throws JspException { 43 String value = bodyContent.getString().trim(); 44 if (blank){ 45 try { 46 for (int i = 0; i < tiles; i++) { 47 TilesUtil.doInclude("/WEB-INF/theme/default/blankActionLink.jspf", pageContext); 48 } 49 } catch (IOException e1) { 50 e1.printStackTrace(); 51 throw new JspException (e1); 52 } catch (ServletException e2) { 53 e2.printStackTrace(); 54 throw new JspException (e2); 55 } 56 } 57 else{ 58 TagUtils 59 .getInstance() 60 .write(pageContext, value); 61 } 62 return (EVAL_PAGE); 63 } 64 65 public int getTiles() { 66 return tiles; 67 } 68 69 public void setTiles(int tiles) { 70 this.tiles = tiles; 71 } 72 } 73 | Popular Tags |