Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 从原始HTML获取图像元素_Image_Gwt_Jsni - Fatal编程技术网

Image 从原始HTML获取图像元素

Image 从原始HTML获取图像元素,image,gwt,jsni,Image,Gwt,Jsni,我的应用程序通过SafeHTMLBuilder创建弹出窗口。我想将点击处理程序(ResizeOnClick)添加到此img 我知道如果我使用uiBinder,我可以添加ui:field标记: @UiField Image ... image.addClickhandler(...); 在我的例子中,我认为我应该使用JSNI,但我无法想象它看起来是什么样子 SafeHtmlBuilder html = new SafeHtmlBuilder(); html.a

我的应用程序通过SafeHTMLBuilder创建弹出窗口。我想将点击处理程序(ResizeOnClick)添加到此img

我知道如果我使用uiBinder,我可以添加ui:field标记:

   @UiField
   Image 
   ...
    image.addClickhandler(...);
在我的例子中,我认为我应该使用JSNI,但我无法想象它看起来是什么样子

SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<div class=\"detailsPopup\">")
        .append(TEMPLATES.image(record.getImageUrl()))
        .appendHtmlConstant("</div>")
SafeHtmlBuilder html=new SafeHtmlBuilder();
html.appendHtmlConstant(“”)
.append(TEMPLATES.image(record.getImageUrl()))
.appendHtmlConstant(“”)
图像模板

  @Template("<img id=\"img\" src=\"{0}\"/>")
   SafeHtml image(String url);
@模板(“”)
安全HTML图像(字符串url);
您可以通过以下方法实现这一点。您的代码看起来像这样(未经测试)

或者像这样简单地使用


您能否提供使用SafeThmBuilder构建的弹出窗口的代码?
 Element element = new Element();
 element.setInnerSafeHtml(html.toSafeHtml());
 Label label = new Label();
 label.wrap(element);
 label.addClickHandler....
$("#detailsPopup").click(new Function() { 
 public boolean f(Event e){
    Window.alert("This is GWT code without widget baggage!");
     return true;
  }
});