001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.taglib.ui;
022:
023: import com.liferay.portal.kernel.servlet.StringServletResponse;
024: import com.liferay.portal.kernel.util.StringPool;
025: import com.liferay.portal.model.Theme;
026: import com.liferay.portal.util.WebKeys;
027: import com.liferay.taglib.util.ParamAncestorTagImpl;
028: import com.liferay.taglib.util.ThemeUtil;
029:
030: import javax.servlet.RequestDispatcher;
031: import javax.servlet.ServletContext;
032: import javax.servlet.http.HttpServletRequest;
033: import javax.servlet.jsp.JspException;
034:
035: /**
036: * <a href="BoxTag.java.html"><b><i>View Source</i></b></a>
037: *
038: * @author Brian Wing Shun Chan
039: *
040: */
041: public class BoxTag extends ParamAncestorTagImpl {
042:
043: public int doStartTag() {
044: return EVAL_BODY_BUFFERED;
045: }
046:
047: public int doAfterBody() {
048: _bodyContentString = getBodyContent().getString();
049:
050: return SKIP_BODY;
051: }
052:
053: public int doEndTag() throws JspException {
054: try {
055: ServletContext ctx = getServletContext();
056: HttpServletRequest req = getServletRequest();
057: StringServletResponse res = getServletResponse();
058:
059: Theme theme = (Theme) req.getAttribute(WebKeys.THEME);
060:
061: // Top
062:
063: if (isTheme()) {
064: ThemeUtil.include(ctx, req, res, pageContext, getTop(),
065: theme);
066: } else {
067: RequestDispatcher rd = ctx
068: .getRequestDispatcher(getTop());
069:
070: rd.include(req, res);
071: }
072:
073: pageContext.getOut().print(res.getString());
074:
075: // Body
076:
077: pageContext.getOut().print(_bodyContentString);
078:
079: // Bottom
080:
081: //res = getServletResponse();
082: res.recycle();
083:
084: if (isTheme()) {
085: ThemeUtil.include(ctx, req, res, pageContext,
086: getBottom(), theme);
087: } else {
088: RequestDispatcher rd = ctx
089: .getRequestDispatcher(getBottom());
090:
091: rd.include(req, res);
092: }
093:
094: pageContext.getOut().print(res.getString());
095:
096: return EVAL_PAGE;
097: } catch (Exception e) {
098: throw new JspException(e);
099: } finally {
100: clearParams();
101: }
102: }
103:
104: public boolean isTheme() {
105: return false;
106: }
107:
108: public String getTop() {
109: return _top;
110: }
111:
112: public void setTop(String top) {
113: _top = top;
114: }
115:
116: public String getBottom() {
117: return _bottom;
118: }
119:
120: public void setBottom(String bottom) {
121: _bottom = bottom;
122: }
123:
124: private String _top;
125: private String _bottom;
126: private String _bodyContentString = StringPool.BLANK;
127:
128: }
|