KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > taglib > MessageAddTag


1 package example.taglib;
2
3 import javax.servlet.jsp.*;
4 import javax.servlet.jsp.tagext.*;
5
6 public class MessageAddTag extends TagSupport {
7   /* tag attributes */
8   String JavaDoc _text;
9
10   /* internal member variables */
11   MessageTag _parentTag;
12   
13   public void setText(String JavaDoc text)
14   {
15     _text = text;
16   }
17
18   public int doStartTag()
19     throws JspException
20   {
21     // initialize internal member variables
22
init();
23
24     _parentTag.addToMessage(_text);
25
26     return SKIP_BODY;
27   }
28
29   private void init()
30     throws JspException
31   {
32     _parentTag = (MessageTag) findAncestorWithClass(this,MessageTag.class);
33     if (_parentTag == null)
34       throw new JspException("Could not find parent MessageTag");
35   }
36 }
37
38
Popular Tags