tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Westgate <n...@key-planning.co.jp>
Subject Re: Newbie and form submission (rewinding resetting values)
Date Fri, 02 Mar 2007 05:07:10 GMT
Hi Damian.

The "set up" is only being done once: when the Person is null.
We create a new one to be edited, and we do this at the first
available opportunity, which is the render phase, since this
occurs before the first rewind.

(Keep in mind that the rewind phase is exactly the same as a render
phase except for (a) its purpose, which is to assign values back to
bound properties etc, and (b) that the HTML result is discarded.)

So that is a common pattern for initialization in pageBeginRender:
if (not rewinding)
     if (object1 is null)
        init object1;
     if (object2 is null)
        init object2;

The only other change was the @Persist annotation to tell Tapestry
to preserve the field's value. The default behaviour is for field
values to be discarded - we must specify which fields are stateful.

This default is reasonable since we want to minimize stored state.
Tapestry performs a lot of magic for us - we just have to remember
where it stops. ;-)

These concepts are no doubt covered in the first 4 free chapters of
Kent Tong's book. Check them out if you haven't read them yet.


Damian Sobieralski wrote:
> Nick,
>  Thank you!! That did the trick.
>  Granted, I am new to this so this might be an asinine question - but
> why do I have to "set up" the form to be re-displayed on a validation
> error?  I mean, when would one rewind after a validation and NOT want
> the form values pre-filled in with their previously submitted values?
> Shouldn't that be the natural/default behavior and I'd only "overrule"
> this behavior if I had a reason?
>  I understand that this is the way it works. I guess I'm just wondering
> why it was designed this way (probably something very reasonable that I
> am not aware of)?
>  Anyways, this was most frustrating. But upto this point I was having
> fun with Tapestry.  So I can continue on with the learning.
> Thanks again for scooting me on my way in the adventure!
> - Damian

To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

View raw message