-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I thought the purpose of Bandbox and Bandpopup is to create a fancy autocomplete. But I can't seems to find a way to update the Bandpopup when the popup is already opened.
Basically I created the onChanging event listener and as user is typing I would try to update the content of the Bandpopup, which is Listbox in my case. However, the Bandpopup content does not seems to be updatable when it is in the opened state. When I manually close and open the popup by either clicking on the Magnifying glass icon or clicking anywhere else then it popup is updated.
Is this a bug or am I not understanding how to use Bandbox?
I am using ZK 5 and Firefox 3.6.13 by the way.
This is my zul:
<div id="searchDiv" apply="${searchModuleController}"> <bandbox id="searchBox" onChanging="searchModuleController.onChangingSearchBox()"> <bandpopup id="searchBoxPopup" height="100px"> <vbox> <listbox id="popupListBox" width="200px" onSelect="searchBox.value=self.selectedItem.label; searchBox.close();"> </listbox> </vbox> </bandpopup> </bandbox> </div>
This is my Java Controller:
import java.util.List; import org.apache.commons.lang.StringUtils; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Sessions; import org.zkoss.zul.Bandbox; import org.zkoss.zul.Bandpopup; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listitem; import org.zkoss.zul.Vbox; @Component("searchModuleController") @Scope("page") public class SearchModuleController extends CBBaseController { private Bandbox searchBox; private Listbox popupListBox; private Bandpopup searchBoxPopup; public void doAfterCompose(org.zkoss.zk.ui.Component comp) throws Exception { super.doAfterCompose(comp); } public void onChangingSearchBox() { String text = searchBox.getText(); searchBox.setOpen(false); if(StringUtils.isNotBlank(text)) { int size = popupListBox.getChildren() == null?0: popupListBox.getChildren().size(); for (int i = 0; i < size; i++) { popupListBox.removeItemAt(0); } text = StringUtils.trim(text); for(int i=0; i<5; i++) { popupListBox.appendChild(new Listitem(text+i)); } popupListBox.renderAll(); } searchBox.setOpen(true); } }
You can refer to this demo.
Hi jumperchen
It is fully functional, for example if you search for an item which is not in the list and then remove that typed characters, then list is not showing all the items again.
There are similar questions in the forum , but not getting any idea how to implement in better way
Asked: 2011-05-02 18:28:03 +0800
Seen: 478 times
Last updated: Nov 01 '13