On Thu, Jan 3, 2013 at 5:12 PM, Alex Kotchnev <akoch...@gmail.com> wrote:

> Now, as far as I  understand, @Persist("session") stores the value in the
> session, keyed on the component class (e.g. thus in component A, a field
> "@Persist private String fooMessage" would/could store a different value
> than "@Persist private String fooMessage" in component B). However,  I'm
> not 100% clear is whether if I have "@Persist private String fooMessage" in
> two different instances of the component - would they have the same value
>  ?
>

See http://tapestry.apache.org/persistent-page-data.html:

"A suitably long session attribute name is used; it incorporates the name
of the page, the nested component id, and the name of the field."

It means that every component instance has its own persisted values.
However when one component instance is rendered multiple times
(e.g. inside Loop or via repeated Delegate to the same Block),
than the same set of persisted values is used.

My rule of thumb regarding @Persist('session') fields:
put them only in page classes or components
that are supposed to be rendered only once per page (e.g. a layout
component).

Other components might access persisted data via parameter bindings.

Best regards,
Cezary

Reply via email to