KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > javascript > ScriptHeader


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.javascript;
19
20 import org.apache.beehive.netui.tags.AbstractClassicTag;
21 import org.apache.beehive.netui.tags.rendering.ScriptTag;
22 import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
23 import org.apache.beehive.netui.tags.rendering.WriteRenderAppender;
24
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26 import javax.servlet.jsp.JspException JavaDoc;
27
28 /**
29  * ScriptHeader will write the <script> and JavaScript includes into the HTML <head> tag.
30  * @jsptagref.tagdescription ScriptHeader will write the <script> and JavaScript includes into
31  * the HTML <head> tag.
32  *
33  * <p>This tag is required to be empty. It is also required when using the &lt;netui:tree> element
34  * with the attribute runAtClient="true".
35  * @netui:tag name="scriptHeader" body-content="empty"
36  * description="ScriptHeader will write the &lt;script> and JavaScript includes into the HTML &lt;head> tag."
37  */

38 public class ScriptHeader extends AbstractClassicTag
39 {
40     /**
41      * Returns the name of the Tag.
42      */

43     public String JavaDoc getTagName()
44     {
45         return "ScriptHeader";
46     }
47
48     /**
49      * Process the start of the Button.
50      * @throws javax.servlet.jsp.JspException if a JSP exception has occurred
51      */

52     public int doStartTag() throws JspException JavaDoc
53     {
54         IScriptReporter sr = getScriptReporter();
55         HttpServletRequest JavaDoc req = (HttpServletRequest JavaDoc) pageContext.getRequest();
56
57         // write out the dynamic content
58
WriteRenderAppender writer = new WriteRenderAppender(pageContext);
59         ScriptRequestState srs = ScriptRequestState.getScriptRequestState(req);
60         srs.writeFeature(sr, writer, CoreScriptFeature.DYNAMIC_INIT, true, false, new Object JavaDoc[]{req.getContextPath()});
61
62         // write out the include
63
ScriptTag.State state = new ScriptTag.State();
64         TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SCRIPT_TAG, pageContext.getRequest());
65
66         state.src = req.getContextPath() + "/resources/beehive/version1/javascript/netui-tree.js";
67         br.doStartTag(writer, state);
68         br.doEndTag(writer);
69
70         return EVAL_BODY_INCLUDE;
71     }
72
73     public int doEndTag()
74             throws JspException JavaDoc
75     {
76         localRelease();
77         return EVAL_PAGE;
78     }
79
80     protected void localRelease()
81     {
82         super.localRelease();
83     }
84 }
85
Popular Tags