KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ditchnet > jsp > taglib > tabs > handler > PrevTabButtonTag


1 /*
2  * The contents of this file are subject to the GNU Lesser General Public
3  * License Version 2.1 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of
5  * the License at http://www.gnu.org/copyleft/lesser.html
6  *
7  * Software distributed under the License is distributed on an "AS
8  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9  * implied. See the License for the specific language governing
10  * rights and limitations under the License.
11  *
12  * Developer:
13  * Todd Ditchendorf, todd@ditchnet.org
14  *
15  */

16
17 /**
18  * @author Todd Ditchendorf
19  * @version 0.8
20  * @since 0.8
21  */

22 package org.ditchnet.jsp.taglib.tabs.handler;
23
24 import java.io.StringWriter JavaDoc;
25 import java.io.IOException JavaDoc;
26 import javax.servlet.jsp.JspContext JavaDoc;
27 import javax.servlet.jsp.JspException JavaDoc;
28 import javax.servlet.jsp.tagext.SimpleTagSupport JavaDoc;
29
30
31 /**
32  * @author Todd Ditchendorf
33  * @since 0.8
34  *
35  * JSP Tag that renders an XHTML </code>input</code> element of type
36  * </code>button</code> with a JavaScript handler to switch the focus of
37  * a specified tab container to the previous tab index.
38  */

39 public final class PrevTabButtonTag extends SimpleTagSupport JavaDoc {
40     
41     private String JavaDoc id;
42     private String JavaDoc tabContainerId;
43     
44     public void setId(final String JavaDoc id) {
45         this.id = id;
46     }
47     
48     public void setTabContainerId(final String JavaDoc tabContainerId) {
49         this.tabContainerId = tabContainerId;
50     }
51     
52     public void doTag() throws IOException JavaDoc, JspException JavaDoc {
53         
54         StringWriter JavaDoc evalResult = new StringWriter JavaDoc();
55         StringBuffer JavaDoc buff = evalResult.getBuffer();
56         
57         buff.append("\n\t<input type=\"button\" ")
58             .append("class=\"ditch-prev-tab-button\" ")
59             .append("onclick=\"org.ditchnet.jsp.")
60             .append("TabUtils.prevTabButtonClicked(event,'")
61             .append(tabContainerId).append("'); return false;\"");
62         if (null != id && 0 != id.length()) {
63             buff.append(" id=\"").append(id).append("\"");
64         }
65         buff.append(" value=\"");
66         getJspBody().invoke(evalResult);
67         buff.append("\" />\n");
68         
69         getJspContext().getOut().print(buff);
70         
71     }
72     
73 }
74
Popular Tags