1
22
23 package com.liferay.taglib.ui;
24
25 import com.liferay.portal.kernel.servlet.StringServletResponse;
26 import com.liferay.portal.kernel.util.StringPool;
27 import com.liferay.portal.model.Theme;
28 import com.liferay.portal.util.WebKeys;
29 import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
30 import com.liferay.taglib.util.ThemeUtil;
31
32 import javax.servlet.RequestDispatcher;
33 import javax.servlet.ServletContext;
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.jsp.JspException;
36
37
43 public class BoxTag extends ParamAndPropertyAncestorTagImpl {
44
45 public int doStartTag() {
46 return EVAL_BODY_BUFFERED;
47 }
48
49 public int doAfterBody() {
50 _bodyContentString = getBodyContent().getString();
51
52 return SKIP_BODY;
53 }
54
55 public int doEndTag() throws JspException {
56 try {
57 ServletContext servletContext = getServletContext();
58 HttpServletRequest request = getServletRequest();
59 StringServletResponse stringResponse = getServletResponse();
60
61 Theme theme = (Theme)request.getAttribute(WebKeys.THEME);
62
63
65 if (isTheme()) {
66 ThemeUtil.include(
67 servletContext, request, stringResponse, pageContext,
68 getTop(), theme);
69 }
70 else {
71 RequestDispatcher requestDispatcher =
72 servletContext.getRequestDispatcher(getTop());
73
74 requestDispatcher.include(request, stringResponse);
75 }
76
77 pageContext.getOut().print(stringResponse.getString());
78
79
81 pageContext.getOut().print(_bodyContentString);
82
83
85 stringResponse.recycle();
87
88 if (isTheme()) {
89 ThemeUtil.include(
90 servletContext, request, stringResponse, pageContext,
91 getBottom(), theme);
92 }
93 else {
94 RequestDispatcher requestDispatcher =
95 servletContext.getRequestDispatcher(getBottom());
96
97 requestDispatcher.include(request, stringResponse);
98 }
99
100 pageContext.getOut().print(stringResponse.getString());
101
102 return EVAL_PAGE;
103 }
104 catch (Exception e) {
105 throw new JspException(e);
106 }
107 finally {
108 clearParams();
109 clearProperties();
110 }
111 }
112
113 public boolean isTheme() {
114 return false;
115 }
116
117 public String getTop() {
118 return _top;
119 }
120
121 public void setTop(String top) {
122 _top = top;
123 }
124
125 public String getBottom() {
126 return _bottom;
127 }
128
129 public void setBottom(String bottom) {
130 _bottom = bottom;
131 }
132
133 private String _top;
134 private String _bottom;
135 private String _bodyContentString = StringPool.BLANK;
136
137 }