View Javadoc

1   /*
2    * Criado em 08/12/2004
3    *
4    */
5   package ecar.taglib.teste;
6   
7   import java.io.IOException;
8   import java.util.Iterator;
9   import java.util.List;
10  
11  import javax.servlet.jsp.JspException;
12  import javax.servlet.jsp.JspWriter;
13  import javax.servlet.jsp.PageContext;
14  import javax.servlet.jsp.tagext.Tag;
15  
16  /**
17   * @author felipev
18   *
19   */
20  public class TagFilho implements Tag{
21      
22      private List textos;
23      
24      private PageContext page = null;
25      
26      private Tag parent;
27      
28      /**
29       * Inicializa a montagem da tag para ser adicionada na tela de HTML.<br>
30       * 
31       * @author N/C
32  	 * @since N/C
33  	 * @version N/C
34  	 * @return int
35  	 * @throws JspException
36       */
37      public int doStartTag() throws JspException {
38          JspWriter writer = this.page.getOut();
39          StringBuffer s = new StringBuffer();
40          Iterator it = textos.iterator();
41          
42          TagPai tagPai = (TagPai) getParent();
43          
44          while(it.hasNext())
45              s.append(it.next()).append("e o label da Tag Pai é ").append(tagPai.getLabel()).append(" <BR> " );
46          try {
47              writer.print(s.toString());
48          } catch (IOException e) {
49  			org.apache.log4j.Logger.getLogger(this.getClass()).error(e);
50          }
51          return Tag.EVAL_BODY_INCLUDE;
52      }
53      
54      /**
55       * Atribui valor especificado para PageContext page.<br>
56       * 
57       * @author N/C
58  	 * @since N/C
59  	 * @version N/C
60  	 * @param PageContext arg0
61       */
62      public void setPageContext(PageContext arg0) {
63  		this.page = arg0;
64  	}
65  
66      /**
67       * Atribui valor especificado para Tag parent.<br>
68       * 
69       * @author N/C
70  	 * @since N/C
71  	 * @version N/C
72  	 * @param Tag arg0
73       */
74  	public void setParent(Tag arg0) {
75  	    parent = arg0;
76  	}
77  
78  	/**
79  	 * Retorna Tag parent.<br>
80  	 * 
81  	 * @author N/C
82  	 * @since N/C
83  	 * @version N/C
84  	 * @return Tag
85  	 */
86  	public Tag getParent() {
87  		return parent;
88  	}
89  	
90  	/**
91  	 * Encerra Tag.<br>
92  	 * 
93  	 * @author N/C
94  	 * @since N/C
95  	 * @version N/C
96  	 * @return int
97  	 * @throws JspException
98  	 */
99  	public int doEndTag() throws JspException {
100 		return Tag.EVAL_PAGE;
101 	}
102 
103 	/**
104 	 * 
105 	 * 
106 	 * @author N/C
107 	 * @since N/C
108 	 * @version N/C
109 	 */
110 	public void release() {
111 		//this.selected = null;
112 	}
113 	
114     /**
115      * Retorna PageContext page.<br>
116      * 
117      * @author N/C
118 	 * @since N/C
119 	 * @version N/C
120      * @return PageContext - (Returns the page)
121      */
122     public PageContext getPage() {
123         return page;
124     }
125     
126     /**
127      * Atribui valor especificado para PageContext page.<br>
128      * 
129      * @author N/C
130 	 * @since N/C
131 	 * @version N/C
132      * @param PageContext page - (The page to set)
133      */
134     public void setPage(PageContext page) {
135         this.page = page;
136     }
137 
138 
139     /**
140      * Retorna List textos.<br>
141      * 
142      * @author N/C
143 	 * @since N/C
144 	 * @version N/C
145      * @return List - (Returns the textos)
146      */
147     public List getTextos() {
148         return textos;
149     }
150     
151     /**
152      * Atribui valor especificado para List textos.<br>
153      * 
154      * @author N/C
155 	 * @since N/C
156 	 * @version N/C
157      * @param List textos - (The textos to set)
158      */
159     public void setTextos(List textos) {
160         this.textos = textos;
161     }
162 }