KickJava   Java API By Example, From Geeks To Geeks.

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


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.JspException JavaDoc;
22 import javax.servlet.jsp.JspTagException JavaDoc;
23 import javax.servlet.jsp.PageContext JavaDoc;
24 import javax.servlet.jsp.tagext.JspFragment JavaDoc;
25 import javax.servlet.jsp.tagext.SimpleTagSupport JavaDoc;
26 import java.io.IOException JavaDoc;
27
28 /**
29  * <p>Body of this tag will be rendered if and only if there are no rows in grid to display.</p>
30  * <br />
31  * This tag is only valid when nested within <em>grid</em> tag.</p>
32  * <p><a HREF="NoRowsTag.java.htm"><i>View Source</i></a></p>
33  *
34  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
35  * @version $Revision: 1.8 $ $Date: 2005/10/12 13:34:56 $
36  * @jsp.tag name="noRows"
37  * body-content="scriptless"
38  */

39 public class NoRowsTag extends SimpleTagSupport JavaDoc {
40
41     protected transient final Log log = LogFactory.getLog(NoRowsTag.class);
42
43     /**
44      * Processes the tag
45      *
46      * @throws JspException
47      * @throws IOException
48      */

49     public void doTag() throws JspException JavaDoc, IOException JavaDoc {
50
51         PageContext JavaDoc pageContext = (PageContext JavaDoc) getJspContext();
52
53         GridTag parentGridTag = (GridTag) findAncestorWithClass(this, GridTag.class);
54         if ( parentGridTag == null ) {
55             JspTagException JavaDoc e = new JspTagException JavaDoc("Parent tag is invalid! This tag is only valid when nested within 'grid' tag");
56             throw e;
57         }
58
59         if ( parentGridTag.getGrid().getTotal().intValue() == 0 ) {
60             JspFragment JavaDoc body = getJspBody();
61             if ( body != null ) {
62                 body.invoke(null);
63             }
64         }
65     }
66 }
67
Popular Tags