GWT CellTable中的超链接单元格
我在GWT中有一个包含textcells和buttoncell的单元格表,现在我想在我的单元格表中添加一个hyperlinkCell,这可能吗GWT CellTable中的超链接单元格,gwt,Gwt,我在GWT中有一个包含textcells和buttoncell的单元格表,现在我想在我的单元格表中添加一个hyperlinkCell,这可能吗 TextCell jobStatusCell = new TextCell(); jobStatusColumn = new Column<EmployerJobs, String>(jobStatusCell) { @Override public String g
TextCell jobStatusCell = new TextCell();
jobStatusColumn = new Column<EmployerJobs, String>(jobStatusCell) {
@Override
public String getValue(EmployerJobs object) {
// int status = object.getJobStatusId();
/*
* if(status ==1) { return ""; } else
*/
// return "post job";
return "view";
}
};
谢谢你是说这个吗?
如果没有,您可以编写一个普通的超链接(
),并将其作为单元格的内容。您的意思是?
如果没有,您可以编写一个普通的超链接(
),并将其作为单元格的内容。尝试使用以下单元格实现
确保将单元格的值作为两个字符串对象的数组提供,如:
String[] value = new String[2];
value[HyperTextCell.LINK_INDEX] = "http://www.google.com";
value[HyperTextCell.TEXT_INDEX] = "Search on google";
public class HyperTextCell extends AbstractCell<String[]> {
interface Template extends SafeHtmlTemplates {
@Template("<a target=\"_blank\" href=\"{0}\">{1}</a>")
SafeHtml hyperText(SafeUri link, String text);
}
private static Template template;
public static final int LINK_INDEX = 0, URL_INDEX = 1;
/**
* Construct a new ImageCell.
*/
public HyperTextCell() {
if (template == null) {
template = GWT.create(Template.class);
}
}
@Override
public void render(Context context, String[] value, SafeHtmlBuilder sb) {
if (value != null) {
// The template will sanitize the URI.
sb.append(template.hyperText(UriUtils.fromString(value[LINK_INDEX]), value[URL_INDEX]));
}
}
}
String[]value=新字符串[2];
值[HyperTextCell.LINK_INDEX]=”http://www.google.com";
值[HyperTextCell.TEXT_INDEX]=“在谷歌上搜索”;
公共类HyperTextCell扩展了AbstractCell{
接口模板扩展了安全HtmlTemplates{
@模板(“”)
安全HTML超文本(安全URI链接,字符串文本);
}
私有静态模板;
公共静态最终int-LINK_-INDEX=0,URL_-INDEX=1;
/**
*构建一个新的ImageCell。
*/
公共超文本单元格(){
如果(模板==null){
template=GWT.create(template.class);
}
}
@凌驾
公共void呈现(上下文上下文,字符串[]值,SafeHtmlBuilder sb){
if(值!=null){
//模板将清理URI。
sb.append(template.hyperText(UriUtils.fromString(value[LINK\u INDEX]),value[URL\u INDEX]);
}
}
}
尝试使用以下单元格实现
确保将单元格的值作为两个字符串对象的数组提供,如:
String[] value = new String[2];
value[HyperTextCell.LINK_INDEX] = "http://www.google.com";
value[HyperTextCell.TEXT_INDEX] = "Search on google";
public class HyperTextCell extends AbstractCell<String[]> {
interface Template extends SafeHtmlTemplates {
@Template("<a target=\"_blank\" href=\"{0}\">{1}</a>")
SafeHtml hyperText(SafeUri link, String text);
}
private static Template template;
public static final int LINK_INDEX = 0, URL_INDEX = 1;
/**
* Construct a new ImageCell.
*/
public HyperTextCell() {
if (template == null) {
template = GWT.create(Template.class);
}
}
@Override
public void render(Context context, String[] value, SafeHtmlBuilder sb) {
if (value != null) {
// The template will sanitize the URI.
sb.append(template.hyperText(UriUtils.fromString(value[LINK_INDEX]), value[URL_INDEX]));
}
}
}
String[]value=新字符串[2];
值[HyperTextCell.LINK_INDEX]=”http://www.google.com";
值[HyperTextCell.TEXT_INDEX]=“在谷歌上搜索”;
公共类HyperTextCell扩展了AbstractCell{
接口模板扩展了安全HtmlTemplates{
@模板(“”)
安全HTML超文本(安全URI链接,字符串文本);
}
私有静态模板;
公共静态最终int-LINK_-INDEX=0,URL_-INDEX=1;
/**
*构建一个新的ImageCell。
*/
公共超文本单元格(){
如果(模板==null){
template=GWT.create(template.class);
}
}
@凌驾
公共void呈现(上下文上下文,字符串[]值,SafeHtmlBuilder sb){
if(值!=null){
//模板将清理URI。
sb.append(template.hyperText(UriUtils.fromString(value[LINK\u INDEX]),value[URL\u INDEX]);
}
}
}
超级链接单元仍然是一种东西吗?你的链接把我带到了别处。@StealthRabbi询问者从未确认过他指的是哪个超链接细胞。GWT从来没有提供过一个,所以我只是在谷歌上搜索并放了第一个。不过,我也不确定这是不是他用过的。不过,你的答案中的链接并没有把我带到一个叫做HyperlinkCell的类。至少,我在源链接中找不到它。超链接单元格仍然是一种东西吗?你的链接把我带到了别处。@StealthRabbi询问者从未确认过他指的是哪个超链接细胞。GWT从来没有提供过一个,所以我只是在谷歌上搜索并放了第一个。不过,我也不确定这是不是他用过的。不过,你的答案中的链接并没有把我带到一个叫做HyperlinkCell的类。至少,我在源链接中找不到它。