Thanks for the great explanation Brian, really brilliant :)

Just another question, you mentioned a basic form, is there an advanced one?
If so, what's the difference between them?

Regards

On 8/9/06, Brian Duchek <[EMAIL PROTECTED]> wrote:

Couple things are real close to your understanding. Here's a quick list
of things to fill in a couple gaps that took me months to grok. :)

* Pages render when requested by a browser, AND when a form is submitted
to them. This is a fact of the framework.
* cycle.isRewinding() identifies the rendering of the page when it is
resolving a form submission. The good news is that it's fast. It only
renders the elements in the form, and discards most of the presentation
html.
* The reason your listener is getting called twice is likely a common
pitfall with forms - you probably put a listener on your form AND on the
submit button. Only one is needed for basic forms - use the form
listener so users can hit Enter to submit the form.
* If your form submission goes right back to the same page, then you can
definitely expect two pageBeginRenders to get called. One is the rewind
of the form, and the next is the re-rendering of the page for display.

There's a slight chance that something quirky is going on causing your
form to actually double-post to the server. That would be a client-side
bug, and might take some browser testing tools to discover.

</bd>



-----Original Message-----
From: Harry Harris [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 09, 2006 5:37 AM
To: [email protected]
Subject: 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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to