package org.icefaces.application.showcase; import java.lang.reflect.Method; import java.util.List; import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; import edu.emory.mathcs.backport.java.util.Arrays; public class Element { private List suggestions = Arrays.asList(new SelectItem[]{ new SelectItem(new Suggestion("Hello"), "Hello"), new SelectItem(new Suggestion("Goodbye"), "Goodbye")}); private String value = ""; public Element() { } public void setSuggestions(List suggestions) { this.suggestions = suggestions; } public List getSuggestions() { return suggestions; } public void autoCompleteInputValueChanged(ValueChangeEvent event) { System.err.println("Event Source = " + event.getComponent()); try { Method method = event.getComponent().getClass().getDeclaredMethod("getSelectedItem", new Class[0]); SelectItem selectedItem = (SelectItem) method.invoke(event.getComponent(), new Object[0]); if (selectedItem != null) { System.err.println("Selected Item Found ..... " + selectedItem); } } catch (Exception e) { e.printStackTrace(); } } public void setValue(String value) { System.out.println("Element.setValue() value: " + value); this.value = value; } public String getValue() { return value; } }