KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > taglib > core > grid > QueryParameterTag


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.taglib.core.grid;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21 import javax.servlet.jsp.JspTagException JavaDoc;
22 import javax.servlet.jsp.PageContext JavaDoc;
23 import javax.servlet.jsp.tagext.SimpleTagSupport JavaDoc;
24
25 /**
26  * <p>Adds additional parameter to query that will be constructed to get rows
27  * of grid.
28  * <br />
29  * This tag is only valid when nested within <em>grid</em> tag.
30  * </p>
31  * <p>
32  * Allowed attributes are:
33  * <ul>
34  * <li>
35  * <b>name</b> - required - name of query parameter to be added
36  * </li>
37  * <li>
38  * <b>value</b> - required - value of query parameter to be added
39  * </li>
40  * </ul>
41  * </p>
42  * <p><a HREF="QueryParameterTag.java.htm"><i>View Source</i></a></p>
43  *
44  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
45  * @version $Revision: 1.8 $ $Date: 2005/10/24 15:06:22 $
46  * @jsp.tag name="queryParameter"
47  * body-content="empty"
48  */

49 public class QueryParameterTag extends SimpleTagSupport JavaDoc {
50
51     protected transient final Log log = LogFactory.getLog(QueryParameterTag.class);
52
53     /**
54      * Name of query parameter
55      */

56     protected String JavaDoc name;
57
58     /**
59      * Parameter value
60      */

61     protected Object JavaDoc value;
62
63     /**
64      * Returns name of parameter
65      *
66      * @return parameter name
67      * @jsp.attribute required="true"
68      * rtexprvalue="true"
69      * type="java.lang.String"
70      * description="Name of query parameter"
71      */

72     public String JavaDoc getName() {
73         return name;
74     }
75
76     /**
77      * Sets name of parameter
78      *
79      * @param name parameter name to set
80      */

81     public void setName(String JavaDoc name) {
82         this.name = name;
83     }
84
85     /**
86      * Returns value of parameter
87      *
88      * @return parameter value
89      * @jsp.attribute required="true"
90      * rtexprvalue="true"
91      * type="java.lang.Object"
92      * description="Parameter value"
93      */

94     public Object JavaDoc getValue() {
95         return value;
96     }
97
98     /**
99      * Sets value of parameter
100      *
101      * @param value parameter value to set
102      */

103     public void setValue(Object JavaDoc value) {
104         this.value = value;
105     }
106
107     /**
108      * Processes the tag
109      *
110      * @throws JspTagException
111      */

112     public void doTag() throws JspTagException JavaDoc {
113
114         PageContext JavaDoc pageContext = (PageContext JavaDoc) getJspContext();
115
116         GridTag parentGridTag = (GridTag) findAncestorWithClass(this, GridTag.class);
117
118         if ( parentGridTag == null ) {
119             JspTagException JavaDoc e = new JspTagException JavaDoc("Parent tag is invalid! This tag is only valid when nested within 'grid' tag");
120             throw e;
121         }
122
123         parentGridTag.getGrid().addQueryParameter(name, value);
124     }
125
126 }
127
Popular Tags