Package org.apache.beehive.netui.tags.javascript

Source Code of org.apache.beehive.netui.tags.javascript.ScriptHeader

/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Header:$
*/
package org.apache.beehive.netui.tags.javascript;

import org.apache.beehive.netui.tags.AbstractClassicTag;
import org.apache.beehive.netui.tags.rendering.ScriptTag;
import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
import org.apache.beehive.netui.tags.rendering.WriteRenderAppender;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;

/**
* ScriptHeader will write the <script> and JavaScript includes into the HTML <head> tag.
* @jsptagref.tagdescription ScriptHeader will write the <script> and JavaScript includes into
* the HTML <head> tag.
*
* <p>This tag is required to be empty. It is also required when using the &lt;netui:tree> element
* with the attribute runAtClient="true".
* @netui:tag name="scriptHeader" body-content="empty"
* description="ScriptHeader will write the &lt;script> and JavaScript includes into the HTML &lt;head> tag."
*/
public class ScriptHeader extends AbstractClassicTag
{
    /**
     * Returns the name of the Tag.
     */
    public String getTagName()
    {
        return "ScriptHeader";
    }

    /**
     * Process the start of the Button.
     * @throws javax.servlet.jsp.JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException
    {
        IScriptReporter sr = getScriptReporter();
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();

        // write out the dynamic content
        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        ScriptRequestState srs = ScriptRequestState.getScriptRequestState(req);
        srs.writeFeature(sr, writer, CoreScriptFeature.DYNAMIC_INIT, true, false, new Object[]{req.getContextPath()});

        // write out the include
        ScriptTag.State state = new ScriptTag.State();
        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SCRIPT_TAG, pageContext.getRequest());

        state.src = req.getContextPath() + "/resources/beehive/version1/javascript/netui-tree.js";
        br.doStartTag(writer, state);
        br.doEndTag(writer);

        return EVAL_BODY_INCLUDE;
    }

    public int doEndTag()
            throws JspException
    {
        localRelease();
        return EVAL_PAGE;
    }

    protected void localRelease()
    {
        super.localRelease();
    }
}
TOP

Related Classes of org.apache.beehive.netui.tags.javascript.ScriptHeader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.