function render()

in wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js [788:856]


		function render(adjustScroll, adjustHeight) {
			var menu=getAutocompleteMenu();
			var height=0;
			var node=getSelectableElement(0);
			var re = /\bselected\b/gi;
			var sizeAffected = false;
			var input=Wicket.$(ajaxAttributes.c);

			for(var i=0;i<elementCount;i++)
			{
				var origClassNames = node.className;
				var classNames = origClassNames.replace(re, "");

				if(selected===i){
					classNames += " selected";

					if (node && node instanceof HTMLElement && node.attributes) {
						node.setAttribute("aria-selected", "true");
						input.setAttribute("aria-activedescendant", node.id);
					}

					if (adjustScroll) {
						adjustScrollOffset(menu.parentNode, node);
					}
				}
				else {
					if (node && node instanceof HTMLElement && node.attributes) {
						node.setAttribute("aria-selected", "false");
					}
				}

				if (classNames !== origClassNames) {
					node.className = classNames;
				}

				if (cfg.maxHeight > -1) {
					height+=node.offsetHeight;
				}
				node = node.nextSibling;
			}
			if (cfg.maxHeight > -1) {
				if (initialDelta === -1)
				{
					// remember size occupied by parent border, padding, and menu+ul margins, border, padding
					initialDelta = menu.parentNode.offsetHeight - height;
				}
				if (height + initialDelta > cfg.maxHeight) {
					var newH = cfg.maxHeight - containerBorderWidths[1];
					menu.parentNode.style.height = (newH >= 0 ? newH : cfg.maxHeight) + "px";
					sizeAffected = true;
				} else if (menu.parentNode.style.height !== "auto") { // if height is limited
					// this also changes the scroll, in some cases we don't want that
					if (adjustHeight)
					{
						menu.parentNode.style.height = "auto"; // no limiting, let popup determine it's own height
					}
					sizeAffected = true;
				}
			}
			if (cfg.useSmartPositioning && !cfg.adjustInputWidth && menu.parentNode.style.width !== "auto" && selChSinceLastRender) {
				// selected item has different padding - so the preferred width of the popup might want to change so as not to wrap it
				selChSinceLastRender = false;
				menu.parentNode.style.width = "auto";
				sizeAffected = true;
			}
			if (sizeAffected) {
				calculateAndSetPopupBounds(Wicket.$(ajaxAttributes.c), menu.parentNode);
			} // update stuff related to bounds if needed
		}