1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| public class ToolTipTag extends TagSupport {
//the id for DHTML
String id;
String text;
String href;
String cssClass;
String cssId;
Logger logger = Logger.getLogger(ToolTipTag.class);
/**
* @return Returns the cssClass.
*/
public String getCssClass() {
return this.cssClass;
}
/**
* @param cssClass The cssClass to set.
*/
public void setCssClass(String cssClass) {
this.cssClass = cssClass;
}
/**
* @return Returns the cssId.
*/
public String getCssId() {
return this.cssId;
}
/**
* @param cssId The cssId to set.
*/
public void setCssId(String cssId) {
this.cssId = cssId;
}
/**
* @return Returns the href.
*/
public String getHref() {
return this.href;
}
/**
* @param href The href to set.
*/
public void setHref(String href) {
this.href = href;
}
/**
* @return Returns the id.
*/
public String getId() {
return this.id;
}
/**
* @param id The id to set.
*/
public void setId(String id) {
this.id = id;
}
/**
* @return Returns the text.
*/
public String getText() {
return this.text;
}
/**
* @param text The text to set.
*/
public void setText(String text) {
this.text = text;
}
/**
* @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
*/
public int doEndTag() throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.write("</a>");
} catch (IOException ioe) {
throw new JspException(ioe);
}
return TagSupport.EVAL_PAGE;
}
/**
* @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
*/
public int doStartTag() throws JspException {
String text_ = text!=null?(String)ExpressionEvaluatorManager.evaluate("text", this.text, String.class,this, super.pageContext ):null;
String id_ = getId_(id);
String href_ = href!=null?(String)ExpressionEvaluatorManager.evaluate("href", this.href, String.class,this, super.pageContext ):null;
String cssClass_ =cssClass!=null?(String)ExpressionEvaluatorManager.evaluate("cssClass", this.cssClass, String.class,this, super.pageContext ):null;
String cssId_ = cssId!=null?(String)ExpressionEvaluatorManager.evaluate("cssId", this.cssId, String.class,this, super.pageContext ):null;
JspWriter writer = pageContext.getOut();
try {
writer.write("<div id='infobulle"+id_+"' style='position:absolute;z-index: 1000;top: 0px;left: 0px;'></div>\n");
writer.write("<a ");
if (href_!=null&&!"".equals(href_))
writer.write("href='"+href_+"' ");
if (cssClass_!=null&&!"".equals(cssClass_))
writer.write("class='"+cssClass_+"' ");
if (cssId_!=null&&!"".equals(cssId_))
writer.write("id='"+cssId_+"' ");
writer.write("onmouseover=\"javascript:helpOver(event,'infobulle"+id_+"','"+text_+"')\" ");
writer.write("onmouseout=\"javascript:helpOut('infobulle"+id_+"')\">");
} catch (IOException ioe) {
throw new JspException(ioe);
}
return TagSupport.EVAL_BODY_INCLUDE;
}
/**
* get the id with expression language or generate automatically if null
* @param id2 the id to extract (if present)
* @return a generated id or extracted id
* @throws JspException
*/
private String getId_(String id2) throws JspException {
String result =null;
if (id2!=null) {
result = (String)ExpressionEvaluatorManager.evaluate("id", this.id, String.class,this, super.pageContext );
logger.debug("id is extract from EL : "+ result);
}
else {
String sToolTipId = (String)pageContext.getAttribute("toolTipId");
int iToolTipId = sToolTipId==null?0:Integer.parseInt(sToolTipId)+1;
result=String.valueOf(iToolTipId);
pageContext.setAttribute("toolTipId",result);
logger.debug("id is set to : "+result);
}
return result;
}
} |
Partager