且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何在UiBinder中为GWT小部件设置ID?

更新时间:2022-12-01 21:24:47

检查模块文件(* .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");