自動提案アイテムで入力テキストを作成します
<af:inputText label="Seller" id="Seller"
valueChangeListener="#{managedBeanTest.OnChangeSeller}" autoSubmit="true"
autoComplete="on">
<af:autoSuggestBehavior suggestedItems="#{managedBeanTest.OnSearchSellers}"/>
</af:inputText>
SelectItem 値をクラス Item に設定します
public class Test
{
public static class Item
{
public Item(int id, String code, String name) { ... }
public String toString() { ... }
}
public List<SelectItem> OnSearchSellers(String search)
{
ResultSet rs;
...
List<SelectItem> result = new ArrayList<SelectItem>();
while (rs.next())
result.add(new SelectItem(new Item(rs.getInt(1), rs.getString(2), rs.getString(3))));
return result;
}
public void OnChangeSeller(ValueChangeEvent valueChangeEvent)
{
Object newVal = valueChangeEvent.getNewValue();
if(newVal != null)
System.out.println("OnChangeSeller: " + newVal.getClass().getName());
}
}
しかし、OnChangeSeller には java.lang.String しかありません。元の選択したアイテムの値 (Item クラス) を取得するにはどうすればよいですか?