KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > mlw > vlh > web > tag > ControlsTag


1 /**
2  * Copyright (c) 2003 held jointly by the individual authors.
3  *
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation; either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; with out even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation,
16  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  *
18  * > http://www.gnu.org/copyleft/lesser.html
19  * > http://www.opensource.org/licenses/lgpl-license.php
20  */

21 package net.mlw.vlh.web.tag;
22
23 import java.util.Locale JavaDoc;
24
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26 import javax.servlet.jsp.JspException JavaDoc;
27
28 import net.mlw.vlh.ValueList;
29 import net.mlw.vlh.web.ValueListConfigBean;
30 import net.mlw.vlh.web.tag.support.ColumnInfo;
31 import net.mlw.vlh.web.util.JspUtils;
32
33 /**
34  * This tag creates a column in a row with "listeners for actions".
35  *
36  * @todo Document this tag.
37  *
38  * @author Andrej Zachar
39  * @version $Revision: 1.6 $ $Date: 2005/11/23 15:02:16 $
40  * @deprecated use vlh:column with omitted parameters 'property'
41  */

42 public class ControlsTag extends BaseColumnTag
43 {
44
45    /**
46     * @see javax.servlet.jsp.tagext.Tag#doStartTag()
47     */

48    public int doStartTag() throws JspException JavaDoc
49    {
50
51       if (bodyContent != null)
52       {
53          bodyContent.clearBody();
54       }
55
56       //If the valuelist is empty, skip the tag...
57

58       ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
59
60       ValueList valueList = rootTag.getValueList();
61       if (valueList == null || rootTag.getValueList().getList() == null || rootTag.getValueList().getList().size() == 0)
62       {
63          return SKIP_BODY;
64       }
65       else
66       {
67          return super.doStartTag();
68       }
69    }
70
71    /**
72     * @see javax.servlet.jsp.tagext.Tag#doEndTag()
73     */

74    public int doEndTag() throws JspException JavaDoc
75    {
76       ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
77       ValueListConfigBean config = rootTag.getConfig();
78       DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);
79       appendClassCellAttribute(rowTag.getRowStyleClass());
80       Locale JavaDoc locale = config.getLocaleResolver().resolveLocale((HttpServletRequest JavaDoc) pageContext.getRequest());
81
82       if (rowTag.getCurrentRowNumber() == 0)
83       {
84          String JavaDoc titleKey = getTitleKey();
85          String JavaDoc label = (titleKey == null) ? getTitle() : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);
86
87          ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, label), null, null, getAttributes());
88          
89          // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
90
String JavaDoc toolTipKey = getToolTipKey();
91          columnInfo.setToolTip((toolTipKey == null) ? getToolTip() : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey,
92                locale));
93
94          rowTag.addColumnInfo(columnInfo);
95       }
96
97       StringBuffer JavaDoc sb = new StringBuffer JavaDoc(rowTag.getDisplayProvider().getCellPreProcess(getCellAttributes()));
98
99       //AAA doesIncludeBodyContent need it here? or it is needed in controls? i think no!, or add some new features to display providers?
100

101       if (bodyContent != null && bodyContent.getString() != null && bodyContent.getString().trim().length() > 0)
102       {
103          sb.append(bodyContent.getString().trim());
104          bodyContent.clearBody();
105       }
106       sb.append(rowTag.getDisplayProvider().getCellPostProcess());
107       JspUtils.write(pageContext, sb.toString());
108
109       release();
110
111       return EVAL_PAGE;
112    }
113 }
Popular Tags