01: /**
02: * Copyright 2007 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: **/package org.araneaframework.jsp.tag.basic;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.jsp.tag.BaseTag;
20: import org.araneaframework.jsp.util.JspUtil;
21:
22: /**
23: * @author Taimo Peelo (taimo@araneaframework.org)
24: *
25: * @since 1.1
26: * @jsp.tag
27: * name = "tooltip"
28: * body-content = "empty"
29: * description =
30: * "Defines tooltip that is shown when end-user hovers over element to which the tooltip was attached."
31: */
32: public class ToolTipHtmlTag extends BaseTag {
33: protected String element;
34: protected String text;
35: protected String options;
36:
37: protected int doStartTag(Writer out) throws Exception {
38: super .doStartTag(out);
39:
40: JspUtil.writeOpenStartTag(out, "script");
41: JspUtil.writeAttribute(out, "type", "text/javascript");
42: JspUtil.writeCloseStartTag_SS(out);
43: out.write("new Tip($('" + element + "'), \"" + text + "\"");
44: if (options != null)
45: out.write(", " + options);
46: out.write(");");
47: JspUtil.writeEndTag(out, "script");
48: return SKIP_BODY;
49: }
50:
51: /**
52: * @jsp.attribute
53: * type = "java.lang.String"
54: * required = "true"
55: * description = "HTML element id to which tooltip should be attached."
56: */
57: public void setElement(String element) throws JspException {
58: this .element = (String) evaluate("element", element,
59: String.class);
60: }
61:
62: /**
63: * @jsp.attribute
64: * type = "java.lang.String"
65: * required = "true"
66: * description = "Tooltip content."
67: */
68: public void setText(String text) throws JspException {
69: this .text = (String) evaluate("text", text, String.class);
70: }
71:
72: /**
73: * @jsp.attribute
74: * type = "java.lang.String"
75: * required = "false"
76: * description = "Options for tooltip (including tooltip classname, title, etc -- see prototip.js for details)."
77: */
78: public void setOptions(String options) throws JspException {
79: this .options = (String) evaluate("options", options,
80: String.class);
81: }
82: }
|