Thursday, September 23, 2010

Re: Basic purpose of onEnsureDebugId

On 23 September 2010 10:54, Hilco Wijbenga <hilco.wijbenga@gmail.com> wrote:
> On 16 July 2010 02:14, Thomas Broyer <t.broyer@gmail.com> wrote:
>> On 16 juil, 06:26, Aditya <007aditya.b...@gmail.com> wrote:
>>> 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)
>
> I just found out about ensureDebugId precisely because I want to use
> Selenium to test our GWT app. I don't clearly understand why this is a
> debug only thing. What is the reason you don't want this in
> production? Is it simply because all those ids take up a lot of space?
>
> The consequence of only having a debug id is that I need to have two
> versions of the app, a production version and a test version. I can do
> that but I'd like to be clear on why the extra effort is worth it. :-)

It looks like it's up to the developer to make sure the ids are
unique. I don't get any complaints from GWT when I reuse an id (on the
same page). Is this something that I can ask the GWT compiler to check
for?

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

No comments:

Post a Comment