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

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

问题描述

在Java代码中,我们可以设置ID。是否有可能在UiBinder中为GWT小部件设置'id'?



如果可以,请给我一个样本。



其实我试过下面的代码,

 < g:Button ui:field =logindebugId =loginButton> 

然后在alert中检查它。 Window.alert(Id:+ login.getElement()。getId());
但输出是 Id:



没有为登录按钮设置ID

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



任何人都可以帮助我吗?



在此先感谢您,
Gnik
p>

解决方案

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

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

然后拨打保留解除ID(元素,ID)方法:

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


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">

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

Id is not set for the login button

Is there any better way to do this?

Can anyone help me?

Thanks in advance, Gnik

解决方案

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

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

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

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

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

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