正在尝试在我的GWT cellTable中添加一些链接单元格

正在尝试在我的GWT cellTable中添加一些链接单元格,gwt,Gwt,我正在尝试在我的单元格表中添加链接(我只希望项目加下划线,鼠标悬停时改变符号) 点击我只想发出一个窗口警报 为此,我尝试了以下几种选择:(但没有运气) (一) 最终超链接hyp=新超链接(“测试”、“测试”); 列测试=新列(新的HyperLinkCell()) { @凌驾 公共超链接getValue(EmployerJobs对象) { 返回hyp; } }; 选项1的问题是,它会将我带到导航页面“测试”,而我不想转到任何其他页面,我只想要一个窗口警报 (二) Column test=新列(新

我正在尝试在我的单元格表中添加链接(我只希望项目加下划线,鼠标悬停时改变符号)

点击我只想发出一个窗口警报

为此,我尝试了以下几种选择:(但没有运气)

(一)

最终超链接hyp=新超链接(“测试”、“测试”);
列测试=新列(新的HyperLinkCell())
{
@凌驾
公共超链接getValue(EmployerJobs对象)
{
返回hyp;
}
};
选项1的问题是,它会将我带到导航页面“测试”,而我不想转到任何其他页面,我只想要一个窗口警报

(二)

Column test=新列(新的SafeHtmlCell())
{
@凌驾
公共安全HTML getValue(EmployerJobs对象)
{
SafeHtmlBuilder sb=新的SafeHtmlBuilder();
某人(以下称“测试”);
让某人回到安全地带();
}
}; 
选项2的问题是,我不知道在这里具体返回什么,而且没有下划线

3) 最后,我尝试使用compositecell在我的celltable中添加锚(理想情况下,我希望在一个单元格中有三个不同的锚)

最终锚anc=新锚();
ArrayList=新建ArrayList();
列表。添加(anc);
CompositeCell ancCell=新的CompositeCell(列表);
列testColumn1=新列(单元格){
@凌驾
公共锚点getValue(EmployerJobs对象){
返回anc;
}       
};
选项3给出了一些例外

如果你能帮我完成上述任何一项工作,我将不胜感激


谢谢你,你完全错了。你需要使用类似的东西,或者创建你自己的细胞。示例代码:

    ActionCell.Delegate<String> delegate = new ActionCell.Delegate<String>(){ 
      public void execute(String value) { //this method will be executed as soon as someone clicks the cell
              Window.alert(value);

      } 
    };
    ActionCell<String> cell = new ActionCell<String>(safeHtmlTitle,delegate){

        @Override
        public void render(com.google.gwt.cell.client.Cell.Context context,  //we need to render link instead of default button
                String value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<a href='#'>");
            sb.appendEscaped(value);
            sb.appendHtmlConstant("</a>");
        }
    }; 

    Column testColumn1 = new Column<EmployerJobs, String>(cell) {

        @Override
        public String getValue(EmployerJobs object) { 
            //we have to return a value which will be passed into the actioncell

            return object.name;
        }       
    };
ActionCell.Delegate Delegate=新的ActionCell.Delegate(){
public void execute(String value){//只要有人单击单元格,就会执行此方法
窗口报警(值);
} 
};
ActionCell=新的ActionCell(SafeThMLITLE,委托){
@凌驾
public void render(com.google.gwt.cell.client.cell.Context Context,//我们需要呈现链接而不是默认按钮
字符串值,安全HtmlBuilder sb){
某人以““””号结尾;
}
}; 
列testColumn1=新列(单元格){
@凌驾
公共字符串getValue(EmployerJobs对象){
//我们必须返回一个将被传递到actioncell的值
返回object.name;
}       
};

我建议您阅读官方版的Cell Widgets,因为这几乎是您需要了解的有关Cell Widgets的所有信息。

您完全错了。你需要使用类似的东西,或者创建你自己的细胞。示例代码:

    ActionCell.Delegate<String> delegate = new ActionCell.Delegate<String>(){ 
      public void execute(String value) { //this method will be executed as soon as someone clicks the cell
              Window.alert(value);

      } 
    };
    ActionCell<String> cell = new ActionCell<String>(safeHtmlTitle,delegate){

        @Override
        public void render(com.google.gwt.cell.client.Cell.Context context,  //we need to render link instead of default button
                String value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<a href='#'>");
            sb.appendEscaped(value);
            sb.appendHtmlConstant("</a>");
        }
    }; 

    Column testColumn1 = new Column<EmployerJobs, String>(cell) {

        @Override
        public String getValue(EmployerJobs object) { 
            //we have to return a value which will be passed into the actioncell

            return object.name;
        }       
    };
ActionCell.Delegate Delegate=新的ActionCell.Delegate(){
public void execute(String value){//只要有人单击单元格,就会执行此方法
窗口报警(值);
} 
};
ActionCell=新的ActionCell(SafeThMLITLE,委托){
@凌驾
public void render(com.google.gwt.cell.client.cell.Context Context,//我们需要呈现链接而不是默认按钮
字符串值,安全HtmlBuilder sb){
某人以““””号结尾;
}
}; 
列testColumn1=新列(单元格){
@凌驾
公共字符串getValue(EmployerJobs对象){
//我们必须返回一个将被传递到actioncell的值
返回object.name;
}       
};
我建议您阅读官方版的CellWidget,因为它几乎是您需要了解的关于CellWidget的所有内容

final Anchor anc = new Anchor();
    ArrayList list = new ArrayList();
    list.add(anc);
     CompositeCell ancCell = new CompositeCell(list);
    Column testColumn1 = new Column<EmployerJobs, Anchor>(ancCell) {

        @Override
        public Anchor getValue(EmployerJobs object) {


            return anc;
        }       
    };
    ActionCell.Delegate<String> delegate = new ActionCell.Delegate<String>(){ 
      public void execute(String value) { //this method will be executed as soon as someone clicks the cell
              Window.alert(value);

      } 
    };
    ActionCell<String> cell = new ActionCell<String>(safeHtmlTitle,delegate){

        @Override
        public void render(com.google.gwt.cell.client.Cell.Context context,  //we need to render link instead of default button
                String value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<a href='#'>");
            sb.appendEscaped(value);
            sb.appendHtmlConstant("</a>");
        }
    }; 

    Column testColumn1 = new Column<EmployerJobs, String>(cell) {

        @Override
        public String getValue(EmployerJobs object) { 
            //we have to return a value which will be passed into the actioncell

            return object.name;
        }       
    };