Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks
          項目中客戶提了一個要求,在進(jìn)行完操作離開表格頁面后,如果再回到這個頁面,要求能保存以前離開時的樣子,(排序,過濾和條目屬性等等。)
          剛開始自己研究了一下代碼,新建一個form來儲存TableFacade的limit屬性到session里,實(shí)現(xiàn)了這個功能。
          后來發(fā)想Jmesa本身就有一個stateAttr屬性用來保存狀態(tài),wiki中有詳細(xì)的使用說明:
          State  

          The State interface is used to set and retrieve the table Limit. Implementations will set the Limit so that it can be retrieved at a later time. This is useful so a user can return to a specific table with it filtered, sorted, and paged exactly like they left it.

          All you have to do is set the stateAttr to the parameter to look for in the url, or the attribute in the request, to tip the table off that the Limit in the users session should be used.

          Example

          For example in the TableFacade just pass in the name of the parameter to use:

          TableFacade tableFacade =TableFacadeFactory.createTableFacade(id, request);
          tableFacade.setStateAttr("restore");

          The same goes for using the tags:

          <jmesa:tableFacade
                  id="basic"
                  stateAttr="restore"
                  ...
                  >

          As you can see in the following example, by passing in a parameter of "restore=true" then the table is rendered in the same way that you left it. That is really all there is too it!

          Note: Just be sure that you have a unique table id for each table that you define. Technically the Limit object for each table is stored in the users session keyed by the table id. If the tables are not unique then you will overwrite one Limit with another.



          posted on 2009-01-21 10:51 seal 閱讀(590) 評論(0)  編輯  收藏 所屬分類: web
          主站蜘蛛池模板: 依安县| 佛教| 驻马店市| 九龙城区| 泽普县| 潜江市| 磐安县| 措勤县| 信丰县| 商河县| 乐都县| 横山县| 尉犁县| 满洲里市| 玉山县| 商丘市| 鲁甸县| 什邡市| 黄石市| 富锦市| 军事| 水城县| 贵溪市| 曲沃县| 宣汉县| 和顺县| 镇雄县| 弋阳县| 于都县| 迭部县| 蒙城县| 柏乡县| 宜宾市| 北辰区| 丰县| 高唐县| 惠来县| 浪卡子县| 阿克陶县| 克什克腾旗| 安岳县|