List of usage examples for com.vaadin.ui HasComponents getId
public String getId();
From source file:annis.libgui.IDGenerator.java
License:Apache License
public static String assignID(Component c, String fieldName) { String id = null;/* ww w. j a v a 2s .c o m*/ if (c != null && fieldName != null && !fieldName.isEmpty()) { Preconditions.checkArgument(c.isAttached(), "Component " + c.getConnectorId() + " must be attached before it can get an automatic ID."); id = c.getId(); if (id == null) { // try to get the parent ID HasComponents parent = c.getParent(); if (parent == null || parent instanceof UI) { // use class name as ID id = fieldName; } else { String parentID = parent.getId(); if (parentID == null) { parentID = assignID(parent); } String idBase = parentID + ":" + fieldName; // check that no other child has the same ID int counter = 1; id = idBase; while (childHasID(parent, id)) { id = idBase + "." + counter++; } } c.setId(id); } } return id; }