KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > scrollabletable > www > ScrollableTableCheckTag


1 /*
2  * Copyright (c) 2005 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: ScrollableTableCheckTag.java,v 1.9 2007/01/07 06:14:16 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21  
22 package org.opensubsystems.patterns.scrollabletable.www;
23
24 import java.util.Properties JavaDoc;
25
26 import javax.servlet.jsp.JspException JavaDoc;
27
28 import org.opensubsystems.core.util.Config;
29 import org.opensubsystems.core.www.PageElementCacheTag;
30
31 /**
32  * Custom tag to allow set specific configuration value to affect 'check'
33  * configuration for the scrollable table. This configuration value overrides
34  * the default settings controlling if the table shows/hides checkboxes for each
35  * line. This flag will apply to all tables following this tag on the page. This
36  * attribute works only for tables created using scrolltbl tags content of which
37  * is generated using custom tags derived from ListTag class.
38  *
39  * @version $Id: ScrollableTableCheckTag.java,v 1.9 2007/01/07 06:14:16 bastafidli Exp $
40  * @author Julo Legeny
41  * @code.reviewer Miro Halas
42  * @code.reviewed 1.7 2006/09/25 15:04:58 bastafidli
43  */

44 public class ScrollableTableCheckTag extends PageElementCacheTag
45 {
46    // Attributes ///////////////////////////////////////////////////////////////
47

48    /**
49     * Generated serial version id for this class.
50     */

51    private static final long serialVersionUID = 426490036326966192L;
52
53    /**
54     * Flag if the list should contain a checkboxes included in each row. These
55     * checkboxes will be used for selecting particular item (row) in the list.
56     * This attribute should say true or 1. Not required.
57     */

58    protected String JavaDoc m_strCheck;
59
60    // Constructors /////////////////////////////////////////////////////////////
61

62    /**
63     * Constructor for custom tag.
64     */

65    public ScrollableTableCheckTag()
66    {
67       // Load setting which specify if we can use checkboxes for each line.
68
// This definition has to be in constructor
69
// and not in static definition because of tests.
70
Properties JavaDoc prpSettings;
71       
72       prpSettings = Config.getInstance().getPropertiesSafely();
73       m_strCheck = Config.getBooleanPropertyAsString(
74                              prpSettings,
75                              ScrollableTableTag.WEBUI_LIST_CHECK,
76                              ScrollableTableTag.WEBUI_LIST_CHECK_DEFAULT,
77                              "Flag allowing for scrollable tables to have checkbox"
78                              + " in each line");
79    }
80
81    // Business logic ///////////////////////////////////////////////////////////
82

83    /**
84     * {@inheritDoc}
85     */

86    public int doStartTag(
87    ) throws JspException JavaDoc
88    {
89       super.doStartTag();
90       
91       // Save the id to the page context so that other related tags don't have to
92
// specify it
93
// Cache value for showing checkboxes for each line
94
cache(ScrollableTableTag.SCROLLABLE_TABLE_CHECK, m_strCheck);
95
96       return (EVAL_BODY_INCLUDE);
97    }
98
99    /**
100     * {@inheritDoc}
101     */

102    public int doEndTag(
103    ) throws JspException JavaDoc
104    {
105       super.doEndTag();
106       
107       return (EVAL_PAGE);
108    }
109
110    /**
111     * @return String - If checkbox will be present in each row then this attribute should
112     * say true or 1.
113     */

114    public String JavaDoc getCheck(
115    )
116    {
117       return m_strCheck;
118    }
119
120    /**
121     * @param strCheck - If checkbox will be present in each row then this attribute should
122     * say true or 1.
123     */

124    public void setCheck(
125       String JavaDoc strCheck
126    )
127    {
128       m_strCheck = strCheck;
129    }
130    
131    /**
132     * @param bCheck - If checkbox will be present in each row then this attribute should
133     * say true or 1.
134     */

135    public void setCheck(
136       boolean bCheck
137    )
138    {
139       m_strCheck = Boolean.toString(bCheck);
140    }
141 }
142
Popular Tags