// Ensure all needed items exist and set each item's html to the given
// suggestion.
while (suggestions.hasNext()) {
Item item = ensureItem(itemCount);
Suggestion suggestion = (Suggestion) suggestions.next();
String display = suggestion.getDisplayString();
if (asHTML) {
DOM.setInnerHTML(item.getElement(), display);
} else {
DOM.setInnerText(item.getElement(), display);
}
item.setValue(suggestion.getValue());
++itemCount;
}
if (itemCount == 0) {
throw new IllegalStateException(