KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > toolbar > ImgButtonTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.toolbar;
14
15 import javax.servlet.jsp.JspException JavaDoc;
16 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
17
18 import org.apache.log4j.Logger;
19
20 /**
21  * Image Button is an image (img) with a hyperlink (a) and a target window name
22  */

23 public class ImgButtonTag extends TagSupport JavaDoc {
24
25   // URL
26
private String JavaDoc href;
27   // browser window name, see HTML spec
28
private String JavaDoc target;
29   // Image URL
30
private String JavaDoc img;
31   private String JavaDoc tooltip;
32   private String JavaDoc visibleRef;
33   private String JavaDoc role;
34     private static Logger logger = Logger.getLogger(ImgButtonTag.class);
35
36   public int doStartTag() throws JspException JavaDoc {
37         logger.info("enter");
38    // find the toolbar
39
ToolBarTag tbt = (ToolBarTag)super.findAncestorWithClass(this, ToolBarTag.class);
40     if (tbt == null)
41       throw new JspException JavaDoc("ToolButtonTag must be nested in ToolBarTag");
42     ToolBar tbar = tbt.getToolBar();
43     
44     // create a separator
45
ImgButton btn = new ImgButton(tbar);
46     btn.setImg(getImg());
47     btn.setId(getId());
48     btn.setHref(getHref());
49     btn.setTarget(getTarget());
50     btn.setVisibleExpr(visibleRef);
51     btn.setRole(role);
52     btn.setTooltip(tooltip);
53     
54     tbar.addImgButton(btn);
55         logger.info("leave");
56     return EVAL_BODY_INCLUDE;
57   }
58
59   /**
60    * Returns the href.
61    * @return String
62    */

63   public String JavaDoc getHref() {
64     return href;
65   }
66
67   /**
68    * Returns the target.
69    * @return String
70    */

71   public String JavaDoc getTarget() {
72     return target;
73   }
74
75   /**
76    * Sets the href.
77    * @param href The href to set
78    */

79   public void setHref(String JavaDoc href) {
80     this.href = href;
81   }
82
83   /**
84    * Sets the target.
85    * @param target The target to set
86    */

87   public void setTarget(String JavaDoc target) {
88     this.target = target;
89   }
90
91   /**
92    * Returns the img.
93    * @return String
94    */

95   public String JavaDoc getImg() {
96     return img;
97   }
98
99   /**
100    * Sets the img.
101    * @param img The img to set
102    */

103   public void setImg(String JavaDoc img) {
104     this.img = img;
105   }
106
107   /**
108    * @return
109    */

110   public String JavaDoc getTooltip() {
111     return tooltip;
112   }
113
114   /**
115    * @param string
116    */

117   public void setTooltip(String JavaDoc string) {
118     tooltip = string;
119   }
120
121   /**
122    * @param string
123    */

124   public void setVisibleRef(String JavaDoc string) {
125     visibleRef = string;
126   }
127
128   /**
129    * @param string
130    */

131   public void setRole(String JavaDoc string) {
132     role = string;
133   }
134
135 }
136
Popular Tags