when a form rewinds, the loop executes over the set of objects, in the
same order in which they were originally iterated, so the fields
naturally populate the correct object as the form rewinds.  For this
reason, it is important that the collection you are iterating over
does, indeed, remain in the same order.  Tapestry facilitates this by
storing each object in a hidden field in the form.  By default, it
will just serialize the object.  This is generally a bad idea, as the
serialized data can be quite large.  So a primary key encoder can just
throw the primary key into the hidden field, and then restore the
object just before the loop rewinds.  This is particularly useful if
you are using something like hibernate to persist your objects, since
you don't really want to be manipulating a detached instance of an
entity, anyway.  By using a freshly loaded instance, you have much
less likelihood of a conflict when you commit the changes.

By specifying that a loop is volatile, you are saying that it
shouldn't restore values from the hidden form field.  Instead, it
should just iterate over the supplied collection, even during the
rewind cycle.  This can help prevent a security nightmare - a user can
manipulate your primary keys in the hidden field in order to
potentially load and modify an entity they shouldn't have permission
for, and it can also be useful if the collection cannot change between
requests.  It will execute faster and it will require less data to be
transmitted between client and server.  You will find the same
parameter on the @If component for the same reasons.

No idea what heartbeats is all about.  sorry.  But then, I also don't
see the reference to it in the docs, at least in 4.0.

--sam

On 3/22/07, Bogdan Calmac <[EMAIL PROTECTED]> wrote:
Hi all,

I'm trying to understand how the Loop component works inside a form
and I couldn't find too much info in the docs. My main curiosity is
how do the right objects get updated when the form is submitted. I
would guess it has something to do with the PrimaryKeyEncoder, but how
does tapestry keep track of the actual object? Store it in the
session?

What does the volatile attribute of the loop mean? When should it be used?

Also, in the doc for Loop there is a reference to heartbeats. What is that?

Thanks,

Bogdan.

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



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

Reply via email to