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.
adding a new tab as a custom component but getting "component must be attac
Hi,
I am adding tabs as custom components.
tabs.addTab((Component) component.getComponent(), component.getName(), null);
LOG.debug("Resource url {} ", component.getResourceUrls());
The tabs get added succuesfully. But when it try to get the connecter id the exception occurs. Below is the implementattion of my getReourceUrls method
public ArrayList<String> getResourceUrls() {
LOG.debug("module 1 get resource urls");
final ArrayList<String> urls = new ArrayList<String>();
final Map<ClassResource, Image> resourceUrls = simpleUI.getResourceUrls();
LOG.debug("Resource url in module 1 {} ", resourceUrls);
for (final Map.Entry<ClassResource, Image> resourceUrl : resourceUrls.entrySet()) {
String url;
//LOG.debug("Resource url get value {}", resourceUrl.getValue());
final String protocol = simpleUI.getUI().getCurrent().getPage().getLocation().getScheme();
final String currentUrl = simpleUI.getUI().getCurrent().getPage().getLocation().getAuthority();
final String cid = resourceUrl.getValue().getConnectorId();
final Integer uiId = resourceUrl.getValue().getUI().getUIId();
final String filename = resourceUrl.getKey().getFilename();
url =
protocol + "://" + currentUrl + "/APP/connector/" + uiId + "/" + cid + "/source/" + filename;
urls.add(url);
}
and the exception happens on resourceUrl.getValue().getConnectorId() ..
So, can someone explain about the adding of custom components when do they get initialized, added and attach ..
Hi, "attached" in Vaadin means that the component is added to a UI, so that, if you do component.getParent().getParent()... you get the UI at some point. So in addition to adding your component to the tabsheet, you must also add the tabsheet to some parent and so on, to have the whole hierarchy in the UI before you can call getConnectorId.