Drop down in AutoComplete does not disappear
horowitzathome Jan 5, 2012 5:06 AMThe drop down containing the suggestions does not disappear, if for example a command button is clicked instead of one of the suggested items of the drop down. After that they are visible in the browser window until the reload icon of the browser is clicked.
Here a simple scenario:
- I enter ab and get the two suggestions abc and abd.
- But then, instead of clicking or selecting abc or abd, I click the Clear button.
The action of the bean is called, the AutoComplete entry field is cleared, but the two items of the drop down box remain in the browser window.
Here is the sample to reproduce:
File TestAutoComp.xhtml
// TestAutoCompBean.java
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name = "tacBean")
@SessionScoped
public class TestAutoCompBean extends BaseBean {
private List<String> nameList;
private String name;
public TestAutoCompBean() {
nameList = new ArrayList<String>();
nameList.add("abc");
nameList.add("abd");
}
public List<String> acName(String suggest) {
return nameList;
}
public String clearAction() {
setName(null);
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
I tested it with 4.1.0.Final. Same effect also with elder versions.
Does someone have any ideas what can be wrong?
Best Regards,
Georg
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <f:view> <h:head> </h:head> <h:body> <rich:panel id="acTestPanel"> <h:form> <rich:autocomplete value="#{tacBean.name}" var="val" fetchValue="#{val}" autocompleteMethod="#{tacBean.acName}" autofill="false" mode="ajax" minChars="0"> <h:outputText value="#{val}" /> </rich:autocomplete> <a4j:commandButton value="Clear" title="Clear" action="#{tacBean.clearAction}" render="acTestPanel" /> </h:form> </rich:panel> </h:body> </f:view> </html>