如何在 UiBinder 中为 GWT 小部件设置 ID? [英] How can I set id for GWT widgets in UiBinder?

查看:25
本文介绍了如何在 UiBinder 中为 GWT 小部件设置 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在java代码中我们可以设置id.是否可以在 UiBinder 本身中为 GWT 小部件设置id"?

In java code we can set id. Is it possible to set 'id' for GWT widgets in UiBinder itself?

如果可能,请给我一个样品.

If it is possilbe please give me a sample.

其实我试过下面的代码,

Actually I tried the following code,

<g:Button ui:field="login" debugId="loginButton">

然后我在警报中检查了它.Window.alert("Id: " + login.getElement().getId());但输出是Id:.

Then I checked it in alert. Window.alert("Id: " + login.getElement().getId()); But the output is Id:.

未为登录按钮设置 ID

Id is not set for the login button

有没有更好的方法来做到这一点?

Is there any better way to do this?

有人可以帮我吗?

提前致谢,格尼克

推荐答案

检查模块文件 (*.gwt.xml) 中以下行的可用性:

Check an availability of the following line in your module file (*.gwt.xml ):

<inherits name="com.google.gwt.user.Debug"/> 

并调用 ensureDebugId(Element, id) 方法在您的代码中:

And call the ensureDebugId(Element, id) method in your code:

login.ensureDebugId(login.getElement(), "loginButton");

这篇关于如何在 UiBinder 中为 GWT 小部件设置 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆