001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.tag;
020
021
022import java.io.IOException;
023
024import lucee.commons.lang.StringUtil;
025import lucee.runtime.PageContextImpl;
026import lucee.runtime.exp.ApplicationException;
027import lucee.runtime.exp.PageException;
028
029/**
030* Writes the text specified in the text attribute to the 'head' section of a generated HTML page. 
031*        The cfhtmlhead tag can be useful for embedding CSS code, or placing other HTML tags such, as
032*        META, LINK, TITLE, or BASE in an HTML page header.
033*/
034public final class HtmlHead extends HtmlHeadBodyBase {
035
036        public String getTagName() {
037                return "htmlhead";
038        }
039
040        public void actionAppend() throws IOException, ApplicationException {
041
042                ((PageContextImpl) pageContext).getRootOut().appendHTMLHead(text);
043        }
044
045        public void actionWrite() throws IOException, ApplicationException {
046
047                ((PageContextImpl) pageContext).getRootOut().writeHTMLHead(text);
048        }
049
050        public void actionReset() throws IOException {
051
052                ((PageContextImpl) pageContext).getRootOut().resetHTMLHead();
053        }
054
055        public void actionRead() throws PageException, IOException {
056
057                String str = ((PageContextImpl) pageContext).getRootOut().getHTMLHead();
058                pageContext.setVariable(!StringUtil.isEmpty(variable,true) ? variable : "cfhtmlhead", str);
059        }
060
061        public void actionFlush() throws IOException {
062
063                ((PageContextImpl) pageContext).getRootOut().flushHTMLHead();
064        }
065
066}