An example of using the new textChangeListener, to allow for converted data types:
<ice:selectInputText
rows="15" width="300"
textChangeListener="#
{autoCompleteBean.textChanged}
"
valueChangeListener="#
{autoCompleteBean.valueChanged}
">
<f:convertDateTime type="both" dateStyle="full" timeStyle="full"/>
<f:selectItems value="#
{autoCompleteBean.list}
"/>
</ice:selectInputText>
public void textChanged(TextChangeEvent event) {
String text = (String) event.getNewValue();
if(text == null || text.length() == 0)
{
// The user pressed the DOWN key, so show the full list, or the first few entries, or whatever your policy is
}
else
{
// Use the partial text fragment to determine which subset of the complete list to show
// Add items to list, with null labels, so the component will make them using the f:convertDateTime automatically
// Date d = new Date();
// SelectItem si = new SelectItem(d, null);
// list.add(si);
// If the fragment would fail conversion or validation, and you don't want a FacesMessage to show, then do this:
FacesContext.getCurrentInstance().renderResponse();
}
}
public void valueChanged(ValueChangeEvent event) {
// Once a full value has been typed in or selected, and passed conversion and validation,
// we can access it here
Date d = (Date) event.getNewValue();
// The same thing should be accessible here:
Date d2 = (Date) ( (SelectInputText) event.getComponent() ).getValue();
// In case you need the actual SelectItem that was selected, if one was selected
SelectInputText autoComplete = (SelectInputText) event.getComponent();
if (autoComplete.getSelectedItem() != null)
{
Date d3 = (Date) autoComplete.getSelectedItem().getValue();
}
}
// ArrayList< SelectItem<Date> >
public List getList()
{
return list;
}
We should add usage of the textChangeListener somewhere in the component-showcase.