Solution for Dynamic Id Generation in GWT Applications
Published by Mona on Saturday, February 14, 2009 at 5:30 PM
At first, the workaround for this was to use a locater other than the object id. Other locators include dom, xpath, link, and css.
Although this workaround made testing possible, recording and tweaking the recorded commands in the script became a lengthy process. After recording the script with the dynamic objects , you have to get the name xpath and css and define the object using a different combination of these three locators.
Fortunately , life was made easier when I discovered the following approach that allows you to set a static id for UI elements in the DOM:
DOM.setElementProperty(uiObject.getElement(),"id", "desiredId")
Using this, you do not have to rewrite the recorded code to include the locators. In addition to saving time, this method makes the recorded script both readable and maintainable.



UIWidget has a getElement() method... So:
foo.getElement().setId() works too and may be a touch clearer...
Hi ,
Can you post a working example here.
That would be very helpfull.
Thanks,
Anil