To make your widgets produce id attributes you need to invoke the ensureDebugId method with an id string, e.g.
Label myLabel = new Label("Say something");
myLabel.ensureDebugId("myLabel");
Now, if you run that you still won't get any id attributes. The clue is in the method name ensureDebugId. You actually need to inherit the Debug module in your module descriptor (.gwt.xml) file. The module to inherit is:
<inherits name="com.google.gwt.user.Debug"/>
Now if you view the source of your label you'll see that it has an id attribute, but you might be surprised that it doesn't quite match the id you supplied ("myLabel"). In fact it will say "gwt-debug-myLabel".
better way to setting ids:
ReplyDeletemyWidget.getElement().setId("myWidget");
this way you don't need to inherit Debug module and id would be exactly "myWidget"