KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > form > core > SetFilterForm


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.webapp.form.core;
17
18 import com.blandware.atleap.webapp.taglib.core.grid.util.FilterConditions;
19 import org.apache.struts.action.ActionMapping;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import java.util.Collections JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Map JavaDoc;
25
26 /**
27  * <p>Form bean for set filter
28  * </p>
29  * <p><a HREF="SetFilterForm.java.htm"><i>View Source</i></a></p>
30  * <p/>
31  *
32  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
33  * @version $Revision: 1.10 $ $Date: 2005/08/04 17:25:16 $
34  * @struts.form name="setFilterForm"
35  */

36 public class SetFilterForm extends BaseFilterForm {
37
38     protected String JavaDoc beanId = null;
39     protected String JavaDoc method = null;
40     protected String JavaDoc label = null;
41     protected String JavaDoc value = null;
42     protected String JavaDoc firstCondition = FilterConditions.FIELD_IN_SET;
43     protected Map JavaDoc selectedElements = Collections.synchronizedMap(new HashMap JavaDoc());
44
45     /**
46      * Creates the new instance of SetFilterForm
47      */

48     public SetFilterForm() {
49     }
50
51     /**
52      * Returns ID of bean that will supply set values
53      *
54      * @return bean ID
55      */

56     public String JavaDoc getBeanId() {
57         return beanId;
58     }
59
60     /**
61      * Sets ID of bean that will supply set values
62      *
63      * @param beanId bean ID to set
64      */

65     public void setBeanId(String JavaDoc beanId) {
66         this.beanId = beanId;
67     }
68
69     /**
70      * Returns name of method that will be invoked on bean to obtain set
71      *
72      * @return name of method
73      */

74     public String JavaDoc getMethod() {
75         return method;
76     }
77
78     /**
79      * Sets name of method that will be invoked on bean to obtain set
80      *
81      * @param method name of method to set
82      */

83     public void setMethod(String JavaDoc method) {
84         this.method = method;
85     }
86
87     /**
88      * Returns name of field in class of bean which is showed in select
89      *
90      * @return label
91      */

92     public String JavaDoc getLabel() {
93         return label;
94     }
95
96     /**
97      * Sets name of field in class of bean which is showed in select
98      *
99      * @param label label to set
100      */

101     public void setLabel(String JavaDoc label) {
102         this.label = label;
103     }
104
105     /**
106      * Returns name of field in class of bean which corresponds to label
107      *
108      * @return value
109      */

110     public String JavaDoc getValue() {
111         return value;
112     }
113
114     /**
115      * Sets name of field in class of bean which corresponds to label
116      *
117      * @param value value to set
118      */

119     public void setValue(String JavaDoc value) {
120         this.value = value;
121     }
122
123     /**
124      * Returns first condition
125      *
126      * @return first condition
127      */

128     public String JavaDoc getFirstCondition() {
129         return firstCondition;
130     }
131
132     /**
133      * Sets first condition
134      *
135      * @param firstCondition first condition to set
136      */

137     public void setFirstCondition(String JavaDoc firstCondition) {
138         this.firstCondition = firstCondition;
139     }
140
141     /**
142      * Returns whether element with given name was selected
143      *
144      * @param key key of element
145      * @return whether element with given name was selected
146      */

147     public Object JavaDoc getElement(String JavaDoc key) {
148         if ( selectedElements.containsKey(key) ) {
149             return Boolean.TRUE;
150         } else {
151             return Boolean.FALSE;
152         }
153     }
154
155     /**
156      * Sets selected element value
157      *
158      * @param key key of selected element
159      * @param value value of selected element
160      */

161     public void setElement(String JavaDoc key, Object JavaDoc value) {
162         if ( log.isDebugEnabled() ) {
163             log.debug("Setting element: key=" + key);
164         }
165         selectedElements.put(key, value);
166     }
167
168     /**
169      * Returns mapping from keys of selected elements to their values
170      *
171      * @return mapping from keys of selected elements to their values
172      */

173     public Map JavaDoc getSelectedElements() {
174         return selectedElements;
175     }
176
177     /**
178      * Sets mapping from keys of selected elements to their values
179      *
180      * @param selectedElements mapping from keys of selected elements to their values
181      */

182     public void setSelectedElements(Map JavaDoc selectedElements) {
183         this.selectedElements = selectedElements;
184     }
185
186     /**
187      * Resets all properties to their default values
188      *
189      * @param mapping The ActionMapping used to select this instance
190      * @param request The non-http request we are proceeding
191      */

192     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
193         super.reset(mapping, request);
194         this.firstCondition = FilterConditions.FIELD_IN_SET;
195         this.clearFilter = null;
196         this.selectedElements = Collections.synchronizedMap(new HashMap JavaDoc());
197         this.beanId = null;
198         this.method = null;
199         this.label = null;
200         this.value = null;
201     }
202
203 }
Popular Tags