-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello Experts!!!
I'm still learning zk and its amazing features.
I'm building an application consuming a webservice, retrieving data chunk by chunk, and for that to work i needed to control the paging
Thanks to Mikelara in this post i was able to do that perfectly.
Now i've noticed the page waits till the data is retrieved before showing.I'll like to show the page with empty listbox and then call the webmethod to retrieve the data showing during that period using somthing like :
Clients.showBusy(mybox,"please wait...");
onCreate event
what's the best way to achieve that? i know most people do that and i've checked the EchoEvent demo and i don't know how to leverage on that considering my scenario since i'm using onCreate, and i'm not using the AnnotateDataBinderInit.
the question is which event should i call insted of onCreate? how do i best use Clients.showBusy?
thanks for reading this , here is a snippet of my code
public void onCreate() { try { AddPaginator(); } catch (Exception ex) { logger.info("Error in onCreate event " + ex.getMessage()); logger.debug("Error in onCreate event", ex); } } public void AddPaginator() { Paging pager = pAccountPager; //TODO: get the total from web service int size = services.countPersonalAccount(null); pager.setTotalSize(size); // pager.setTotalSize(size); final int PAGE_SIZE = pager.getPageSize(); redraw(0, PAGE_SIZE); pager.addEventListener("onPaging", new EventListener() { @Override public void onEvent(Event event) { Clients.showBusy(lstPAccount,"Fetching data please wait ..."); PagingEvent pevent = (PagingEvent) event; int pageNo = pevent.getActivePage(); int offset = pageNo * PAGE_SIZE; redraw(offset, PAGE_SIZE); Clients.clearBusy(); } }); }
The problem with your code is that there is no roundtrip to the client between your showBusy(..) and clearBusy()....
Look at this thread from a few months back to see how to use showBusy(...), echoEvent(...), and then clearBusy()...
Hello
Cary Thanks for responding.Sorry for taking this long to give feedback.I've been quite busy off late.
I've modify my code to follow the thoughts that you shared on the other thread.
public void onCreate() { try { AddPaginator(); } catch (Exception ex) { logger.info("Error in onCreate event " + ex.getMessage()); logger.debug("Error in onCreate event", ex); } } public void AddPaginator() { Paging pager = pAccountPager; int size = services.countPersonalAccount(null); pager.setTotalSize(size); pager.setDetailed(true); PAGE_SIZE = pager.getPageSize(); refreshList(); // redraw(0, PAGE_SIZE); pager.addEventListener("onPaging", new EventListener() { @Override public void onEvent(Event event) { PagingEvent pevent = (PagingEvent) event; int pageNo = pevent.getActivePage(); offset = pageNo * PAGE_SIZE; logger.info("Personal Account: logging page offset " + offset + " paging " + PAGE_SIZE); refreshList(); // redraw(offset, PAGE_SIZE); } }); } public void refreshList() { Clients.showBusy(lstPAccount, "Please wait, fetching....."); Events.echoEvent("getListData", pAccountWin, null); } public void getListData(){ redraw(offset, PAGE_SIZE); Clients.clearBusy(lstPAccount); }
Instead of calling redraw method directly i've introduced 2methods refreshList and getListData. i've also make variable offset and PAGE_SIZE global.
but through debugging i've noticed that the method getListData which is called in EchoEvent, is never callled.
So i have the please wait message but then no data is loaded and the showbusy is then showing forever.
i've changed
Events.echoEvent("getListData", this.self, null);
Events.echoEvent("getListData", pAccountWin, null);
Seems it's no going well with EchoEvent. Any help from anybody is welcomed.
thanks for reading this and helping out
ZK requires event names to be like onXX, so you cannot echo/post/send events that don't adhere to that convention.
Otherwise your code looks fine, so I think it will work if you just change getListData to onGetListData.
That works , thank you and Carry for helping out.
Asked: 2011-05-23 14:37:37 +0800
Seen: 390 times
Last updated: May 29 '11