code: public String getId() {
  		if(id == null) {
  			synchronized(lock) {
  				if(id == null) {
  					if(page != null) {
  						Map<String,Element> elementsById = page.getElementsById();
  						// Generate the ID now
  						String template = getElementIdTemplate();
  						if(template == null) {
  							throw new IllegalStateException("null from getElementIdTemplate");
  						}
  						StringBuilder possId = Element.generateIdPrefix(template, getDefaultIdPrefix());
  						int possIdLen = possId.length();
  						// Find an unused identifier
  						for(int i=1; i<=Integer.MAX_VALUE; i++) {
  							if(i == Integer.MAX_VALUE) throw new IllegalStateException("ID not generated");
  							if(i>1) possId.append('-').append(i);
  							String newId = possId.toString();
  							if(
  								elementsById == null
  								|| !elementsById.containsKey(newId)
  							) {
  								setId(newId, true);
  								break;
  							}
  							// Reset for next element number to check
  							possId.setLength(possIdLen);
  						}
  					}
  				}
  			}
  		}
  		return id;
  	}
docs: When inside a page, every element must have a per-page unique ID, when one is not provided, it will be generated.
  When not inside a page, no missing ID is generated and it will remain null.