0

Bandbox onChanging cannot update Bandpopup... I think it is a bug?

asked 2011-05-02 18:28:03 +0800

gsugiart gravatar image gsugiart
12

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);
	}
}

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-05-10 05:15:16 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

You can refer to this demo.

link publish delete flag offensive edit

answered 2013-11-01 07:18:34 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

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.

link publish delete flag offensive edit

answered 2013-11-01 07:26:43 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

updated 2013-11-01 07:27:06 +0800

There are similar questions in the forum , but not getting any idea how to implement in better way

question 1

question 2

question 3

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-05-02 18:28:03 +0800

Seen: 478 times

Last updated: Nov 01 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More