Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Making page data persist across requests to a single page is accomplished with the @Persist annotation. This annotation is applied to private instance fields of components:

Code Block
java
java

  @Persist
  private int value;

...

Code Block
titleExample: Session Strategy

  @Persist
  private int value;

...

Code Block
titleExample: Flash Strategy

  @Persist(PersistenceConstants.FLASH)
  private int value;

...

Code Block
titleExample: Client Strategy

  @Persist(PersistenceConstants.CLIENT)
  private int value;

Hibernate Entity Strategy

Code Block
  @Persist(HibernatePersistenceConstants.ENTITY)
  private User user;

 

Entity persistence is provided by either the tapestry-hibernate modules (which extend Tapestry with new features).

In Entity persistence, the field should store a Hibernate (or JPA) entity instance.

The value stored in the HttpSession is a token for the entity: its Java class name and primary key. When the field is restored in a later request, the entity is reinstantiated using that data.

What is not stored is any changes to the persistent entity that are not committed to the external datastore (the database).

Persistence Strategy Inheritance

...

The method discardPersistentFieldChanges() of ComponentResources will discard all persistent fields for the page, regardless of which strategy is used to store the property. This will not affect the page in memory, but takes effect for subsequent requests.

Include Page
Clustering Issues
Clustering Issues