
Tapestry5中对一个属性使用下列语法
第一点:@Persist的意思是在不同的页面之间,也就是不同的请求之间数据保存的策略,使用的策略是由常量tapestry.persistence-strategy来配置的,如果配置了这个常量值,则以这个值为准,否则就以session策略为准。
第二点:类PersistenceConstants有三个静态常量,分别是session、client和flash。tapestry5
session策略:第一点中就说明了,如果未指定tapestry.persistence-strategy的时候使用session策略,也就是上面代码中的第一种策略,存储的数据是保存在session中的。tapestry5
flash策略:这样的属性数据是存储在客户端,作为查询或者隐藏 form 域用。
flash策略:client策略下的数据也是存储在session中的,但仅仅是持续到下一个请求,通常用来提供给用户的确认信息。
以下是官方对于Tapestry5中的页面持久化数据的介绍
Most instance variables in Tapestry are automatically cleared at the end of each request.
This is important, as it pertains to how Tapestry pages are pooled and shared, over time, by many users.
However, you often want to store some persistent data on a single page, and have access to it in later requests. Long term storage of data should go in a database of some form, but server-side state for the duration of the as user's interaction with the application should go in the HttpSession (though Tapestry provides a few other options as well).
Note: To store values that may be accessed across multiple pages, uses a session state object.
Making a field persistent is accomplished with the Persist annotation. Again, this does not refer to database persistence, it refers to session persistance.
This annotation is applied to private instance fields of components.
Annotated fields will store their state between requests. Generally, speaking, this means that the value is stored into the session (but other approaches are possible).
Whenever you make a change to a persistent field, its value is stored.
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-30936-1.html
只要能杀美国人