KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > collection > CollectionItemTag


1 package fr.improve.struts.taglib.layout.collection;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
5 import javax.servlet.jsp.tagext.BodyTag JavaDoc;
6
7 /**
8  * This tag is used to add a property to display to a tag that can display collections
9  * (the parent tag must be an instanceof BaseCollectionTag)
10  * <br><br>
11  * header - The key of the title to display for this property<br>
12  * property - The property to display<br>
13  * <br>
14  * @see BaseCollectionTag BaseCollectionTag
15  *
16  * @author: Jean-Noel Ribette
17  **/

18 public class CollectionItemTag extends FastCollectionItemTag implements BodyTag JavaDoc {
19     protected BodyContent JavaDoc bodyContent;
20     protected boolean useBody = true;
21     
22     public void doInitBody() throws JspException JavaDoc {
23         // do nothing.
24
}
25     public int doAfterBody() throws JspException JavaDoc {
26         // do nothing.
27
return SKIP_BODY;
28     }
29     public void setBodyContent(BodyContent JavaDoc in_content) {
30         bodyContent = in_content;
31     }
32     
33     public void release() {
34         super.release();
35         bodyContent = null;
36     }
37     
38     public int doStartLayoutTag() throws JspException JavaDoc {
39         int lc_result = super.doStartLayoutTag();
40         if (lc_result==EVAL_BODY_INCLUDE) {
41             return EVAL_BODY_TAG;
42         } else {
43             return lc_result;
44         }
45     }
46     
47     protected Object JavaDoc buildContent() throws JspException JavaDoc {
48         if (bodyContent != null && bodyContent.getString().length() > 0) {
49             // The item to add is the body content of the tag.
50
Object JavaDoc lc_cell = bodyContent.getString();
51             bodyContent.clearBody();
52             useBody = true;
53             return lc_cell;
54         } else {
55             useBody = false;
56             return super.buildContent();
57         }
58     }
59     
60     protected boolean buildFilter() {
61         if (useBody) {
62             return false;
63         } else {
64             return super.buildFilter();
65         }
66     }
67
68     }
69
Popular Tags