gwt 创建 超链接cell (HyperTextCell)
2024-09-19 23:44:48
package com.cnblogs.hooligen.client; import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; public class HyperTextCell extends AbstractCell<String[]> { interface HyperTextTemplate extends SafeHtmlTemplates {
@Template("<a style=\"{0}\">{1}</a>")
SafeHtml hyperText(String styleClass, String value);
} private static HyperTextTemplate template; public HyperTextCell() {
this("click");
} public HyperTextCell(String... consumedEvents) {
super(consumedEvents); if(template == null) {
template = GWT.create(HyperTextTemplate.class);
}
} @Override
public void onBrowserEvent(Context context, Element parent, String[] value,
NativeEvent event, ValueUpdater<String[]> valueUpdater) {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
if("click".equals(event.getType())) {
if (valueUpdater != null) {
valueUpdater.update(value);
}
} } @Override
public void render(Context context, String[] value, SafeHtmlBuilder sb) {
if (value != null && value.length == 2) {
sb.append(template.hyperText(value[0], value[1]));
}
} }
最新文章
- Microsoft Build 2016 Day 1 记录
- HTML5教程之html 5 本地数据库(Web Sql Database)
- A library of generic data structures
- require.js工作原理(初始)
- 完美解决google无法访问
- zabbix常用术语
- linux 配置java 环境
- 夺命雷公狗—angularjs—5—ng-switch的用法实现下拉更换板块的实现
- POJ 1995
- 内存管理算法--Buddy伙伴算法
- WCF入门教程系列三
- web.config中<;customErrors>;节点
- [置顶]
 一个demo学会css
- 为什么要写 tf.Graph().as_default()
- SQL学习指南之查询入门
- 商业版微信小程序开发流程
- js判断手机邮箱格式(正则)
- C#实现接口IHttpModule完成统一的权限验证
- BZOJ2793[Poi2012]Vouchers——枚举
- cube-ui修改按钮颜色
热门文章
- phpcms v9 模板标签说明整理
- How to Analyze Java Thread Dumps--reference
- C# 之 SqlConnection 类
- zTree 异步加载
- Android_SystemService
- 主流存储引擎详解:Innodb,Tokudb、Memory、MYISAM、Federated
- [转]为什么python标准库没有实现链表
- Spring 的@Controller 和@RestController的区别
- JavaScript 一个等号 两个等号 三个等号的区别
- 【C#4.0图解教程】笔记(第9章~第18章)