KickJava   Java API By Example, From Geeks To Geeks.

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


1 package fr.improve.struts.taglib.layout;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4 import javax.servlet.jsp.PageContext JavaDoc;
5 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
6
7 import fr.improve.struts.taglib.layout.util.ParentFinder;
8
9 /**
10  * Abstract LayoutTag implementation.
11  * This class helps :
12  * <ul><li>to develop custom tags that can find their parents even when the jsp is dynamically included in another jsp,</li>
13  * <li>to support dynamically computed value without breaking tag pooling</li></ul>
14  */

15 public abstract class LayoutTagSupport extends TagSupport JavaDoc implements LayoutTag {
16     /**
17      * Return the tag pageContext.
18      */

19   public final PageContext JavaDoc getPageContext() {
20     return pageContext;
21   }
22   
23   /**
24    * Final implemtation of doStartTag.
25    * This method ensures that :
26    * <ul>
27    * <li>the tag is registered in the struts-layout tag stack</li>
28    * <li>the dynamic values are computed</li>
29    * </ul>
30    */

31   public final int doStartTag() throws JspException JavaDoc {
32     ParentFinder.registerTag(pageContext, this);
33     initDynamicValues();
34     return doStartLayoutTag();
35   }
36   
37   /**
38    * Final implementation of doEndTag.
39    * This method ensures that:
40    * <ul>
41    * <li>the tag attribute values are reset to their original values.</li>
42    * <li>the tag is deregistered from the struts-layout tag stack.</li>
43    * </ul>
44    */

45   public final int doEndTag() throws JspException JavaDoc {
46     try {
47       return doEndLayoutTag();
48     } finally {
49       reset();
50       ParentFinder.deregisterTag(pageContext);
51     }
52   }
53   
54   public int doStartLayoutTag() throws JspException JavaDoc {
55     return super.doStartTag();
56   }
57   public int doEndLayoutTag() throws JspException JavaDoc {
58     return super.doEndTag();
59   }
60   
61   /**
62    * Init dynamuc values. This is the place to initialize EL-enabled attributes.
63    */

64   protected void initDynamicValues() {
65     // Do nothing.
66
}
67   
68   /**
69    * Reset dynamic values. This is the place to reset EL-enabled attributes to their jsp values.
70    */

71   protected void reset() {
72     // DO NOTHING, to be override.
73
}
74 }
75
Popular Tags