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;
}
Added a MethodBinding to SelectInputText called textChangeListener, which takes a TextChangeEvent parameter. TextChangeEvent extends ValueChangeEvent, and the whole things acts like ValueChangeEvent/ValueChangeListener. Although the TextChangeEvent is broadcast in the APPLY_REQUEST_VALUES phase and contains the SelectInputText's submittedValue as its new value.
It's purpose is to notify the application that the user has typed in a text fragment into the SelectInputText's text input field, allowing for the application to refine its selection list which will popup. In the case of converted and validated values, which require a complete
input of text, like with a Date, the textChangeListener may call FacesContext.getCurrentInstance().renderResponse() to skip over the validation, and proceed to rendering the popup selection list.
HEAD
Subversion 15838
icefaces\bridge\lib\extras\autocomplete_ext.js
icefaces\component-metadata\src\main\java\com\icesoft\metadata\generators\TagLibraryGenerator.java
icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-selectinputtext-props.xml
icefaces\component\src\com\icesoft\faces\component\facelets\IceComponentHandler.java
icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputText.java
icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputTextRenderer.java
icefaces\component\src\com\icesoft\faces\component\selectinputtext\TextChangeEvent.java
icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\DomBasicRenderer.java
ICEfaces 1.6 branch
Subversion 15839
icefaces\bridge\lib\extras\autocomplete_ext.js
icefaces\component-metadata\src\main\java\com\icesoft\metadata\generators\TagLibraryGenerator.java
icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-selectinputtext-props.xml
icefaces\component\src\com\icesoft\faces\component\facelets\IceComponentHandler.java
icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputText.java
icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputTextRenderer.java
icefaces\component\src\com\icesoft\faces\component\selectinputtext\TextChangeEvent.java
icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\DomBasicRenderer.java