posts - 48, comments - 13, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          tapesty persistence strategy

          Posted on 2009-01-21 16:49 董銳 閱讀(222) 評(píng)論(0)  編輯  收藏
          http://tapestry.apache.org/tapestry5/guide/persist.html

          Most instance variables in Tapestry are automatically cleared at the end of each request.
          通常每次請求結(jié)束,Tapestry會(huì)將實(shí)例變量清空。

          This is important, as it pertains to how Tapestry pages are pooled and shared, over time, by many users.
          這很重要,因?yàn)門apestry的頁面是在緩沖池中被許多用戶共享的。

          However, you often want to store some persistent data on a page, and have access to it in later requests.
          然而,你通常希望在頁面存儲(chǔ)一些持久數(shù)據(jù),這樣后面的請求可以得到這些數(shù)據(jù)。

          This is accomplished with the Persist annotation.

          This annotation is applied to private instance fields.

            @Persist
          private int value;

          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.

          On later requests, the value for such persistent fields is reloaded from storage.



          Persistence Strategies

          The value for each field is the strategy used to store the field between requests.

          session strategy

          The session strategy stores field changes into the session; the session is created as necessary.

          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.

          Session strategy is the default strategy used unless otherwise overridden.

          Session策略是默認(rèn)策略。

          flash strategy

          The flash strategy stores information in the session as well, just for not very long. Values are stored into the session, but then deleted from the session as they are first used to restore a page's state.

          The flash is typically used to store temporary messages that should only be displayed to the user once.

          client strategy

          The field is persisted onto the client; you will see an additional query parameter in each URL (or an extra hidden field in each form).


          Client  持久花費(fèi)的代價(jià)要高些,它會(huì)在渲染頁面的每個(gè)鏈接后面加上數(shù)百字節(jié)的額外信息。

          Client persistence is somewhat expensive. It can bloat the size of the rendered pages by adding hundreds of characters to each link. There is extra processing on each request to de-serialize the values encoded into the query parameter.

          Client persistence does not scale very well; as more information is stored into the query parameter, its length can become problematic. In many cases, web browsers, firewalls or other servers may silently truncate the URL which will break the application. 有時(shí)URL地址太長會(huì)被截掉。

          Use client persistence with care, and store a minimal amount of data. Try to store the identity (that is, primary key) of an object, rather than the object itself.


          只有注冊用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 宁乡县| 华池县| 瓮安县| 页游| 郴州市| 柳河县| 开封市| 桂林市| 紫金县| 南乐县| 通渭县| 甘孜县| 荆州市| 临武县| 南靖县| 乌拉特后旗| 通榆县| 沙河市| 晋宁县| 星子县| 秦安县| 衡南县| 沽源县| 万盛区| 宁武县| 邵东县| 元江| 南昌市| 巧家县| 乌鲁木齐市| 方城县| 长顺县| 土默特左旗| 青河县| 怀安县| 阳高县| 朝阳县| 家居| 新绛县| 轮台县| 石柱|