KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > tags > BlankActionTag


1 package com.sslexplorer.core.tags;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.ServletException JavaDoc;
6 import javax.servlet.jsp.JspException JavaDoc;
7 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
8
9 import org.apache.struts.taglib.TagUtils;
10 import org.apache.struts.tiles.TilesUtil;
11
12 /**
13  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
14  *
15  */

16 public class BlankActionTag extends BodyTagSupport JavaDoc {
17
18     private boolean blank = false;
19     private int tiles = 1;
20
21     /**
22      * Save the associated label from the body content (if any).
23      *
24      * @exception JspException if a JSP exception has occurred
25      */

26     public int doAfterBody() throws JspException JavaDoc {
27
28         if (bodyContent != null) {
29             String JavaDoc 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 JavaDoc {
43         String JavaDoc 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 JavaDoc e1) {
50                 e1.printStackTrace();
51                 throw new JspException JavaDoc(e1);
52             } catch (ServletException JavaDoc e2) {
53                 e2.printStackTrace();
54                 throw new JspException JavaDoc(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