KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > DivTag


1 package fr.improve.struts.taglib.layout;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import fr.improve.struts.taglib.layout.event.StaticCodeIncludeLayoutEvent;
6 import fr.improve.struts.taglib.layout.event.StaticCodeIncludeListener;
7 import fr.improve.struts.taglib.layout.util.TagUtils;
8
9 /**
10  * Tag creating a DIV HTML element.
11  *
12  * This tagimplements the StaticCodeIncludeListener so that DIV generated by Struts-Layout
13  * are positioned out of this DIV.
14  *
15  * This helps positioning of popup (like the calendar)
16  *
17  * @author JN RIBETTE
18  */

19 public class DivTag extends LayoutTagSupport implements StaticCodeIncludeListener {
20     /**
21      * Static HTML code to write.
22      */

23     protected StringBuffer JavaDoc staticCode = new StringBuffer JavaDoc();
24     
25     /**
26      * Attribute styleId
27      */

28     private String JavaDoc styleId;
29     
30     /**
31      * Tag start
32      */

33     public int doStartLayoutTag() throws JspException JavaDoc {
34         // Start DIV.
35
TagUtils.write(pageContext, "<div");
36         
37         // Add id attribute
38
if (styleId!=null) {
39             TagUtils.write(pageContext, " id=\"");
40             TagUtils.write(pageContext, styleId);
41             TagUtils.write(pageContext, "\"");
42         }
43         // end DIV.
44
TagUtils.write(pageContext, ">");
45         
46         // Evaluate tag content.
47
return EVAL_BODY_INCLUDE;
48     }
49     
50     /**
51      * Tag end.
52      */

53     public int doEndLayoutTag() throws JspException JavaDoc {
54         // End DIV.
55
TagUtils.write(pageContext, "</div>");
56         
57         // Write static HTML code.
58
if (staticCode.length()!=0) {
59             TagUtils.write(pageContext, staticCode.toString());
60         }
61         
62         // Evaluate page.
63
return EVAL_PAGE;
64     }
65     
66     /**
67      * Reset this tags.
68      */

69     protected void reset() {
70         super.reset();
71         staticCode = new StringBuffer JavaDoc();
72         styleId = null;
73     }
74
75     /**
76      * Handle StaticCodeIncludeLayoutEvent.
77      */

78     public Object JavaDoc processStaticCodeIncludeEvent(StaticCodeIncludeLayoutEvent in_event) throws JspException JavaDoc {
79         // Envoie le code statique au un listener parent s'il y en a un.
80
String JavaDoc lc_value = (String JavaDoc) in_event.sendToParent(this);
81         
82         // Garde le code statique a générer, s'il n'a pas
83
// été traité par le parent.
84
staticCode.append(lc_value);
85         return "";
86     }
87
88     public String JavaDoc getStyleId() {
89         return styleId;
90     }
91
92     public void setStyleId(String JavaDoc styleId) {
93         this.styleId = styleId;
94     }
95 }
96
Popular Tags