1 /***
2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
6 *
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is pow2WebGui library.
13 *
14 * The Initial Owner of the Original Code is Power Of Two S.R.L.
15 * Portions created by Power Of Two S.R.L. are Copyright (C) Power Of Two S.R.L.
16 * All Rights Reserved.
17 *
18 * Contributor(s):
19 */
20
21 package com.pow2.webgui.taglib;
22
23 import javax.servlet.jsp.JspTagException;
24
25 import com.pow2.util.Util;
26 import com.pow2.webgui.WidgetFactory;
27 import com.pow2.webgui.contentprovider.BaseContentProvider;
28 import com.pow2.webgui.window.Window;
29
30
31 /***
32 * WindowTag class.
33 * <br>
34 * This tag renderers a "window" like theme
35 * around its content.
36 *
37 * @author Luca Fossato
38 * @created 11 June 2001
39 */
40 public class WindowTag extends Window
41 {
42 private WidgetFactory wf = null;
43 private Window win = null;
44
45
46 /***
47 * @return Description of the Return Value
48 * @exception JspTagException Description of the Exception
49 */
50 public int doStartTag() throws JspTagException
51 {
52 return EVAL_BODY_BUFFERED;
53 }
54
55
56 /***
57 * @return Description of the Return Value
58 * @exception JspTagException Description of the Exception
59 */
60 public int doEndTag() throws JspTagException
61 {
62 try
63 {
64 wf = WidgetFactory.instance();
65 win = (Window)wf.getWidget(Window.KEY);
66 win.updateAttributes(this);
67 win.setWidgetDrawer(drawer);
68
69
70 if (!Util.isNull(contentProviderName))
71 {
72 win.setContentProvider(contentProviderName);
73 BaseContentProvider cp = win.getContentProvider();
74
75 if (cp != null)
76 TagUtil.setContentProviderData(cp, pageContext);
77 }
78 }
79 catch (Exception e)
80 {
81 cat.error("::doStartTag - error:", e);
82 throw new JspTagException(e.getMessage());
83 }
84
85
86
87 if (bodyContent != null)
88 {
89 win.setContent(new StringBuffer(bodyContent.getString()));
90
91 try
92 {
93 bodyContent.getEnclosingWriter().print(win.draw());
94 }
95 catch(Exception e)
96 {
97 cat.error("::doAfterBody - error:", e);
98 throw new JspTagException(e.getMessage());
99 }
100 }
101
102 return EVAL_PAGE;
103 }
104 }