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.
482420
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;
	}
147071
function (page) {
        if (!lang.isNumber(page)) {
            page = this.getCurrentPage();
        }

        var perPage = this.get('rowsPerPage'),
            records = this.get('totalRecords'),
            start, end;

        if (!page || !perPage) {
            return null;
        }

        start = (page - 1) * perPage;
        if (records !== Paginator.VALUE_UNLIMITED) {
            if (start >= records) {
                return null;
            }
            end = Math.min(start + perPage, records) - 1;
        } else {
            end = start + perPage - 1;
        }

        return [start,end];
    }
478147
protected int getNextId(ServletRequest req)
    {
        Integer i = (Integer) RequestUtils.getOuterAttribute((HttpServletRequest) req,NETUI_UNIQUE_CNT);
        if (i == null) {
            i = new Integer(0);
        }

        int ret = i.intValue();
        RequestUtils.setOuterAttribute((HttpServletRequest) req,NETUI_UNIQUE_CNT, new Integer(ret + 1));
        return ret;
    }
1022327
public String getElementId() {
		for (Entry<String, String> attribute : attributes.entrySet()) {
			if (attribute.getKey().equalsIgnoreCase("id")) {
				return attribute.getValue();
			}
		}
		return null;
	}
684318
public String id(){
        HttpServletRequest r = RequestContext.getHttpRequest();
        if(r == null){
            return null;
        }
        HttpSession session = r.getSession(false);
        return session == null ? null : session.getId();
    }
583118
function (id) {
            if (ariaCoreBrowser.isIE7) {
                this.getElementById = function (id) {
                    var document = Aria.$window.document;
                    var el = document.getElementById(id);
                    if (el) {
                        // If id match, return element
                        if (el.getAttribute("id") == id) {
                            return el;
                        } else {
                            for (var elem in document.all) {
                                if (elem.id == id) {
                                    return elem;
                                }
                            }
                        }
                    }
                    return null;
                };
            } else {
                this.getElementById = function (id) {
                    var document = Aria.$window.document;
                    return document.getElementById(id);
                };
            }
            return this.getElementById(id);
        }
297667
def _generate_ids(self, document, content):
        
        existing_ids = content.xpath('//*/@id')
        elements = [
            'p', 'dl', 'dt', 'dd', 'table', 'div', 'section', 'figure',
            'blockquote', 'q', 'code', 'pre', 'object', 'img', 'audio',
            'video',
            ]
        elements_xpath = '|'.join(['.//{}|.//xhtml:{}'.format(elem, elem)
                                  for elem in elements])

        data_types = [
            'equation', 'list', 'exercise', 'rule', 'example', 'note',
            'footnote-number', 'footnote-ref', 'problem', 'solution', 'media',
            'proof', 'statement', 'commentary'
            ]
        data_types_xpath = '|'.join(['.//*[@data-type="{}"]'.format(data_type)
                                     for data_type in data_types])

        xpath = '|'.join([elements_xpath, data_types_xpath])

        mapping = {}  # old id -> new id

        for node in content.xpath(xpath, namespaces=HTML_DOCUMENT_NAMESPACES):
            old_id = node.attrib.get('id')
            document_id = document.id.replace('_', '')
            if old_id:
                new_id = 'auto_{}_{}'.format(document_id, old_id)
            else:
                random_number = random.randint(0, 100000)
                new_id = 'auto_{}_{}'.format(document_id, random_number)
            while new_id in existing_ids:
                random_number = random.randint(0, 100000)
                new_id = 'auto_{}_{}'.format(document_id, random_number)
            node.attrib['id'] = new_id
            if old_id:
                mapping[old_id] = new_id
            existing_ids.append(new_id)

        for a in content.xpath('//a[@href]|//xhtml:a[@href]',
                               namespaces=HTML_DOCUMENT_NAMESPACES):
            href = a.attrib['href']
            if href.startswith('#') and href[1:] in mapping:
                a.attrib['href'] = '#{}'.format(mapping[href[1:]])
1228369
public boolean isExistingID() {
        try {
            String userId= getPost().getString(Defines.Jsonkey.Identity.getKey());
            return (userId != null && userId.equals(prefHelper_.getIdentity()));
        } catch (JSONException e) {
            e.printStackTrace();
            return false;
        }

    }
1088146
function (id) {
            var id = id + "";
            if (id && id.indexOf("+") != -1) {
                if (Aria.testMode) {
                    return this.$getAutoId(id);
                }
                return null;
            }
            return this.$getId(id);
        }
1030510
public CmsUUID getId() {

        if (m_id != null) {
            return m_id;
        } else if (m_resource != null) {
            return m_resource.getStructureId();
        } else {
            // only in case of the default element view
            return CmsUUID.getNullUUID();
        }
    }
818166
function( id ) {
			var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ];
			if ( !tab || this._.pageCount == 1 || !tab.isVisible() )
				return;
			// Switch to other tab first when we're hiding the active tab.
			else if ( id == this._.currentTabId )
				this.selectPage( getPreviousVisibleTab.call( this ) );

			tab.hide();
			this._.pageCount--;
			this.updateStyle();
		}
834696
private void initPageData() {

        m_elementInstances = new HashMap<String, CmsContainerElementBean>();
        m_parentContainers = new HashMap<String, CmsContainerBean>();
        if (m_page != null) {
            for (CmsContainerBean container : m_page.getContainers().values()) {
                for (CmsContainerElementBean element : container.getElements()) {
                    m_elementInstances.put(element.getInstanceId(), element);
                    m_parentContainers.put(element.getInstanceId(), container);
                    try {
                        if (element.isGroupContainer(m_cms) || element.isInheritedContainer(m_cms)) {
                            List<CmsContainerElementBean> children;
                            if (element.isGroupContainer(m_cms)) {
                                children = CmsJspTagContainer.getGroupContainerElements(
                                    m_cms,
                                    element,
                                    m_request,
                                    container.getType());
                            } else {
                                children = CmsJspTagContainer.getInheritedContainerElements(m_cms, element);
                            }
                            for (CmsContainerElementBean childElement : children) {
                                m_elementInstances.put(childElement.getInstanceId(), childElement);
                                m_parentContainers.put(childElement.getInstanceId(), container);
                            }
                        }
                    } catch (CmsException e) {
                        LOG.error(e.getLocalizedMessage(), e);
                    }
                }
            }
            // also add detail only data
            if (m_detailOnlyPage != null) {
                for (CmsContainerBean container : m_detailOnlyPage.getContainers().values()) {
                    for (CmsContainerElementBean element : container.getElements()) {
                        m_elementInstances.put(element.getInstanceId(), element);
                        m_parentContainers.put(element.getInstanceId(), container);
                    }
                }
            }
        }
    }
243116
def generate_id
            if self.id.nil?                
                #
                # Generate the id (incrementing values as required)
                #
                overflow = self.class.__overflow__ ||= self.class.bucket.get("#{self.class.design_document}:#{CLUSTER_ID}:overflow", :quiet => true) # Don't error if not there
                count = self.class.bucket.incr("#{self.class.design_document}:#{CLUSTER_ID}:count", :create => true)     # This models current id count
                if count == 0 || overflow.nil?
                    overflow ||= 0
                    overflow += 1
                    # We shouldn't need to worry about concurrency here due to the size of count
                    # Would require ~18446744073709551615 concurrent writes
                    self.class.bucket.set("#{self.class.design_document}:#{CLUSTER_ID}:overflow", overflow)
                    self.class.__overflow__ = overflow
                end
                
                self.id = self.class.__class_id_generator__.call(overflow, count)
                
                
                #
                # So an existing id would only be present if:
                # => something crashed before incrementing the overflow
                # => this is another request was occurring before the overflow is incremented
                #
                # Basically only the overflow should be able to cause issues, we'll increment the count just to be sure
                # One would hope this code only ever runs under high load during an overflow event
                #
                while self.class.bucket.get(self.id, :quiet => true).present?
                    # Set in-case we are here due to a crash (concurrency is not an issue)
                    # Note we are not incrementing the @__overflow__ variable
                    self.class.bucket.set("#{self.class.design_document}:#{CLUSTER_ID}:overflow", overflow + 1)
                    count = self.class.bucket.incr("#{self.class.design_document}:#{CLUSTER_ID}:count")               # Increment just in case (attempt to avoid infinite loops)
                    
                    # Reset the overflow
                    if self.class.__overflow__ == overflow
                        self.class.__overflow__ = nil
                    end

                    # Generate the new id
                    self.id = self.class.__class_id_generator__.call(overflow + 1, count)
                end
            end
        end
331510
public String getId(Widget widget) {

    Element element = widget.getElement();
    return getId(element);
  }
690920
Element getElementById(String name) {
        for (Attr attr : attributes) {
            if (attr.isId() && name.equals(attr.getValue())) {
                return this;
            }
        }

        /*
         * TODO: Remove this behavior.
         * The spec explicitly says that this is a bad idea. From
         * Document.getElementById(): "Attributes with the name "ID"
         * or "id" are not of type ID unless so defined.
         */
        if (name.equals(getAttribute("id"))) {
            return this;
        }

        for (NodeImpl node : children) {
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element element = ((ElementImpl) node).getElementById(name);
                if (element != null) {
                    return element;
                }
            }
        }

        return null;
    }
296652
@Nullable
  String getId() {
    ImmutableList<String> parts = getSegments();

    if (!parts.isEmpty()) {
      return parts.get(parts.size() - 1);
    } else {
      return null;
    }
  }
446493
private String createId(FacesContext context)
            throws JspException {

        if (this.id == null) {
            return getFacesJspId();
        } else {
            // if this tag happens to be nested within <c:forEach>, jspId
            // will be the same for each iteration. So it is
            // transformed into a unique "id" by appending a counter which gets
            // stored in request scope with jspId as the key for use during next
            // iteration.
            if (isDuplicateId(this.id)) {
                if (!isSpecifiedIdUnique(this.id)) {
                    if (isNestedInIterator) {
                        this.id = generateIncrementedId(this.id);
                    } else {
                        StringWriter writer = new StringWriter(128);
                        printTree(context.getViewRoot(), this.id, writer, 0);
                        String msg = "Component ID '"
                                + this.id
                                + "' has already been used"
                                + " in the view.\n"
                                + "See below for the view up to the point of"
                                + " the detected error.\n"
                                + writer.toString();
                        throw new JspException(msg);
                    }
                }
            }
            return (this.id);
        }

    }