Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Where is the "ID" and "NAME" Tag?
Hello!
I was wondering why the Vaadin-GWT-Components don't have an "ID" or a "NAME" . I know about
foo.setDebugId("myDebugId");
but as the method suggest it is only for debugging. Is there a simple way to add an "ID" or a "Name"? I like to reference those fields via external Java-Script and thought that this would be the easiest way to do so.
Thanks,
Chris
Hi,
#setDebugId is the canonical[1] way set the ID attribute on the generated HTML eLement. Despite the name, it *is* always generated.
It is badly named, I agree, but there you have it; changing the method name would cause all sorts of backwards compatibility pain.
I do not believe that there is any way to set the NAME attribute.
Cheers,
Charles.
[1] i.e. the correct, and indeed only way
Hello Charles,
thank you for the quick response. Do you know why the developer initially decided against names and ids? Is there a know issue or conflict using names and ids in Vaadin? I am just wondering since it seems as the easiest way to reference Vaadin generated objects from outside the actual application.
Cheers,
Chris
Hi,
I've no idea - the original developer is probably hanging around here somewhere... I suspect it's probably related to the fact that Vaadin's orignal version didn't generate HTML at all, and so there was no such thing as an ID attribute to generate.
Using setDebugID to set the ID attribute on the HTML element works absolutely fine, and I would recommend you use it; Ihe only "bleuch" thing is that the method in Vaadin is called "setDebugId" not setId!
If you want a different approach, you could always add a css class name to the element (by Component#addStyleName), and search the DOM using JQuery or whatever, but I see no advantage over using id/setDebugId
Cheers,
Charles.
Hello!
Thanks again for the deeper look inside. I really appreciated it.
Cheers,
Chris