KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ajaxanywhere > ZoneTag


1 /*
2 Copyright 2005 Vitaliy Shevchuk (shevit@users.sourceforge.net)
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15
16 */

17
18 package org.ajaxanywhere;
19
20 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
21 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import javax.servlet.jsp.PageContext JavaDoc;
24 import javax.servlet.ServletRequest JavaDoc;
25 import java.io.IOException JavaDoc;
26
27 /**
28  * @jsp.tag name = "zone"
29  * display-name = "zone"
30  * description = ""
31  */

32 public class ZoneTag extends TagSupport JavaDoc {
33     private static final boolean DEFAULT_SKIP_INF_NOT_INCLUDED = false;
34
35     private String JavaDoc name;
36     private boolean skipIfNotIncluded = DEFAULT_SKIP_INF_NOT_INCLUDED;
37
38     public String JavaDoc getName() {
39         return name;
40     }
41
42     /**
43      * @param name String
44      * @jsp.attribute required="true"
45      * rtexprvalue="true"
46      * type="java.lang.String"
47      * description="name description"
48      */

49     public void setName(String JavaDoc name) {
50         this.name = name;
51     }
52
53     public int doStartTag() throws JspException JavaDoc {
54         try {
55             pageContext.getOut().print(AAUtils.getZoneStartDelimiter(name));
56         } catch (IOException JavaDoc e) {
57             throw new JspException JavaDoc(e);
58         }
59
60         ServletRequest JavaDoc request = pageContext.getRequest();
61         if (skipIfNotIncluded
62                 && AAUtils.isAjaxRequest(request)
63                 && !AAUtils.getZonesToRefresh(request).contains(name)
64                 )
65             return SKIP_BODY;
66         else
67             return EVAL_BODY_INCLUDE;
68
69     }
70
71     public int doEndTag() throws JspException JavaDoc {
72         try {
73             pageContext.getOut().print(AAUtils.getZoneEndDelimiter(name));
74         } catch (IOException JavaDoc e) {
75             throw new JspException JavaDoc(e);
76         }
77         return EVAL_PAGE;
78     }
79
80     public int doAfterBody() throws JspException JavaDoc {
81         return super.doAfterBody();
82     }
83
84
85     public void setPageContext(PageContext JavaDoc pageContext) {
86         skipIfNotIncluded = DEFAULT_SKIP_INF_NOT_INCLUDED;
87         super.setPageContext(pageContext);
88     }
89
90     public boolean isSkipIfNotIncluded() {
91         return skipIfNotIncluded;
92     }
93
94     /**
95      * @param skipIfNotIncluded boolean
96      * @jsp.attribute required="false"
97      * rtexprvalue="true"
98      * type="boolean"
99      * description="if the zone is not in the include list, tag content is not evaluated."
100      */

101     public void setSkipIfNotIncluded(boolean skipIfNotIncluded) {
102         this.skipIfNotIncluded = skipIfNotIncluded;
103     }
104 }
105
Popular Tags