KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > listdata > www > ListDataBaseTag


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: ListDataBaseTag.java,v 1.1 2007/02/02 05:44:08 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.listdata.www;
23
24 import javax.servlet.ServletRequest JavaDoc;
25
26 import org.opensubsystems.core.www.PageElementCacheTag;
27 import org.opensubsystems.patterns.listdata.data.DataCondition;
28 import org.opensubsystems.patterns.listdata.data.ListOptions;
29
30 /**
31  * Custom tag to create and insert to the page all form variables required by
32  * the list data pattern. This tag needs to be in a HTML form which can be
33  * submitted to the server to an instance of ListBrowserServlet.
34  *
35  * @version $Id: ListDataBaseTag.java,v 1.1 2007/02/02 05:44:08 bastafidli Exp $
36  * @author Miro Halas
37  * @code.reviewer Miro Halas
38  * @code.reviewed Initial revision
39  */

40 public abstract class ListDataBaseTag extends PageElementCacheTag
41 {
42    // Attributes ///////////////////////////////////////////////////////////////
43

44    /**
45     * Generated serial version UID
46     */

47    private static final long serialVersionUID = -4495791780917057495L;
48
49    /**
50     * Name of the attribute in the request object, which identifies ListOptions
51     * object. If none is specified, the default name used by ListBrowserServlet
52     * will be used.
53     */

54    protected String JavaDoc m_strOptions;
55
56    /**
57     * Name of the attribute in the request object, which identifies
58     * DataCondition object representing extra condition for list options.
59     * If none is specified, the default name used by ListBrowserServlet
60     * will be used.
61     */

62    protected String JavaDoc m_strExtraCondition;
63
64    // Constructors /////////////////////////////////////////////////////////////
65

66    /**
67     * Constructor for custom tag.
68     */

69    public ListDataBaseTag()
70    {
71       super();
72    }
73    
74    // Business logic ///////////////////////////////////////////////////////////
75

76    /**
77     * Get the name of the attribute which identifies ListOptions object. If none
78     * is specified, the default name used by ListBrowserServlet will be used.
79     *
80     * @return String - name of the attribute which identifies ListOptions object
81     */

82    public String JavaDoc getOptions()
83    {
84       return m_strOptions;
85    }
86
87    /**
88     * Sets the name of the attribute which identifies ListOptions object.
89     *
90     * @param strName - name of the attribute which identifies ListOptions object
91     */

92    public void setOptions(
93       String JavaDoc strName
94    )
95    {
96       m_strOptions = strName;
97    }
98
99    /**
100     * Get the name of the attribute which identifies DataCondition object
101     * representing extra condition for list options. If none is specified, the
102     * default name used by ListBrowserServlet will be used.
103     *
104     * @return String - name of the attribute which identifies DataCondition
105     * object representing extra condition for list options.
106     */

107    public String JavaDoc getExtraCondition()
108    {
109       return m_strExtraCondition;
110    }
111
112    /**
113     * Sets the name of the attribute which identifies DataCondition object
114     * representing extra condition for list options. Required.
115     *
116     * @param strName - name of the attribute which identifies DataCondition
117     * object representing extra condition for list options.
118     */

119    public void setExtraCondition(
120       String JavaDoc strName
121    )
122    {
123       m_strExtraCondition = strName;
124    }
125
126    // Helper methods ///////////////////////////////////////////////////////////
127

128    /**
129     * Get list option object for this tag.
130     *
131     * @return ListOptions - list option object to use in this tag.
132     */

133    protected ListOptions getOptionsObject(
134    )
135    {
136       ListOptions listoptions;
137       ServletRequest JavaDoc request = pageContext.getRequest();
138       String JavaDoc strName;
139       
140       strName = getOptions();
141       if ((strName == null) || (strName.length() == 0))
142       {
143          // Try to retrieve the default one
144
strName = ListBrowserServlet.PARAMETER_LIST_OPTIONS_NAME;
145       }
146       listoptions = (ListOptions)request.getAttribute(strName);
147     
148       return listoptions;
149    }
150    
151    /**
152     * Get list option object for this tag.
153     *
154     * @return DataCondition - extra condition object to use in this tag.
155     */

156    protected DataCondition getExtraConditionObject(
157    )
158    {
159       DataCondition extracondition;
160       ServletRequest JavaDoc request = pageContext.getRequest();
161       String JavaDoc strName;
162       
163       strName = getExtraCondition();
164       if ((strName == null) || (strName.length() == 0))
165       {
166          // Try to retrieve the default one
167
strName = ListBrowserServlet.PARAMETER_EXTRA_CONDITION_NAME;
168       }
169       extracondition = (DataCondition)request.getAttribute(strName);
170     
171       return extracondition;
172    }
173 }
174
Popular Tags