On 16 juil, 06:26, Aditya <[email protected]> wrote:
> hello,
>
> Can anyone has answer why is onEnsureDebugId() is used...?
> how does it helps while creating custom widgets.

The whole notion of "debug ID" is only useful if you do run selenium
or webdriver (or similar) tests, and you therefore need widgets to
have an ID, and moreover a *stable* ID. But you generally don't want
that ID to be generated when deploying for production use.
So you'll call ensureDebugId in your code, which in turn will call the
onEnsureDebugId of the widget, but only if you <inherit
name='com.google.gwt.user.Debug' />, otherwise it's a no-op.
Widgets can then override onEnsureDebugId to set an ID not only to
their "root element" but also to child elements. See for instance how
CheckBox overrides onEnsureDebugId to set an ID on the checkbox and
label (remember, CheckBox is a <span> with a <input type=checkbox> and
<label> children).
Calling ensureDebugId("foo") on some CheckBox widget will set an
id="gwt-debug-foo" on the <span>, id="gwt-debug-foo-label" on the
<label> and id="gwt-debug-foo-input" on the <input type=checkbox>.
That way you can write selenium/webdriver/whatever tests that will
generate, say, click events on the document.getElementById("gwt-debug-
foo-input") (i.e. the <input type=checkbox> of your CheckBox widget)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to