You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Harry Harris <hy...@gmail.com> on 2006/08/09 14:37:15 UTC

Help with Page Life cycle

Hello there! I've just started with tapestry, and I was wondering if anyone
cares to give me a little help understanding page life cycle :)

Its a simple crud scenario.
So I have a page that implements PageBeginRenderListener, I read that this
method is called just before page begins to render, so I guessed (of course
I might be wrong :P) that there would be a nice place to initialize some
objects:

public void pageBeginRender(PageEvent event) {
       if(getCurrentUser == null){
         setCurrentUser(new User());
         setUserList(getUserService().getUserList());
        }
    }

Question is: When I'm saving my object this method is called twice, the
first one, for my surprise currentuser was null, then, just after that it's
called again but this time with proper values set (from the page). I was
debugging, and both times cycle.isRewinding() was true. This has a major
impact on my performance, since it hits db twice...

Ok, so I thought that would be the only time that methods were called twice
:(

But the listener associated with the form is also being called twice:

public IPage registerUser(IRquestCycle cycle){
...
}

This method is being called twice, and also the cycle.isRewinding() is true
on both times...

I just would like to have a better view of how things work on tapestry and
how can I avoid those duplicated method calling

My best regards