0

Page is loading listbox data before showing.Is there anything like afterCreate event?

asked 2011-05-23 14:37:37 +0800

blacksensei gravatar image blacksensei
234 2

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...");

my issue is that i'm calling the redraw method in
 onCreate event

and i've looked for something like afterCreate or even overrite the
doAfterCompose thinking it corresponds to some after creation phase.

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

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-05-23 15:13:07 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

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()...

link publish delete flag offensive edit

answered 2011-05-27 18:18:13 +0800

blacksensei gravatar image blacksensei
234 2

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

to
 Events.echoEvent("getListData", pAccountWin, null);

with pAccountWin being the id of the Windon, but still it's not working properly

Seems it's no going well with EchoEvent. Any help from anybody is welcomed.

thanks for reading this and helping out

link publish delete flag offensive edit

answered 2011-05-28 05:29:38 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

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.

link publish delete flag offensive edit

answered 2011-05-29 10:42:40 +0800

blacksensei gravatar image blacksensei
234 2

That works , thank you and Carry for helping out.

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-23 14:37:37 +0800

Seen: 390 times

Last updated: May 29 '11

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