Dev@Free

          zJun's Tech Weblog

          我的評(píng)論

          @xieamao
          dao.query()中是使用Hibernate實(shí)現(xiàn)分頁(yè)的查詢,在有很多現(xiàn)成的實(shí)現(xiàn)。
          @yushibo

          public class Page {

          static private int DEFAULT_PAGE_SIZE = 15;

          /**
          * 每頁(yè)的記錄數(shù)
          */
          private int pageSize = DEFAULT_PAGE_SIZE;

          /**
          * 當(dāng)前頁(yè)第一條數(shù)據(jù)在List中的位置,從0開(kāi)始
          */
          private int start;

          /**
          * 當(dāng)前頁(yè)中存放的記錄
          */
          private List results;

          /**
          * 總記錄數(shù)
          */
          private int totalCount;

          /**
          * 構(gòu)造方法,只構(gòu)造空頁(yè)
          */
          public Page() {
          this(0, 0, DEFAULT_PAGE_SIZE, new ArrayList());
          }

          /**
          * 默認(rèn)構(gòu)造方法
          *
          * @param start
          * 本頁(yè)數(shù)據(jù)在數(shù)據(jù)庫(kù)中的起始位置
          * @param totalSize
          * 數(shù)據(jù)庫(kù)中總記錄條數(shù)
          * @param pageSize
          * 本頁(yè)容量
          * @param results
          * 本頁(yè)包含的數(shù)據(jù)
          */
          public Page(int start, int totalSize, int pageSize, List results) {
          this.pageSize = pageSize;
          this.start = start;
          this.totalCount = totalSize;
          this.results = results;
          }

          /**
          * 取數(shù)據(jù)庫(kù)中包含的總記錄數(shù)
          */
          public int getTotalCount() {
          return this.totalCount;
          }

          /**
          * 取總頁(yè)數(shù)
          */
          public int getTotalPageCount() {
          if (totalCount % pageSize == 0)
          return totalCount / pageSize;
          else
          return totalCount / pageSize + 1;
          }

          /**
          * 取每頁(yè)數(shù)據(jù)容量
          */
          public int getPageSize() {
          return pageSize;
          }

          /**
          * 當(dāng)前頁(yè)記錄
          */
          public List getResults() {
          return results;
          }

          /**
          * 取當(dāng)前頁(yè)碼,頁(yè)碼從1開(kāi)始
          */
          public int getCurrentPageNo() {
          return start / pageSize + 1;
          }

          /**
          * 是否有下一頁(yè)
          */
          public boolean hasNextPage() {
          return this.getCurrentPageNo() < this.getTotalPageCount() - 1;
          }

          /**
          * 是否有上一頁(yè)
          */
          public boolean hasPreviousPage() {
          return this.getCurrentPageNo() > 1;
          }

          /**
          * 獲取任一頁(yè)第一條數(shù)據(jù)的位置,每頁(yè)條數(shù)使用默認(rèn)值
          */
          protected static int getStartOfPage(int pageNo) {
          return getStartOfPage(pageNo, DEFAULT_PAGE_SIZE);
          }

          /**
          * 獲取任一頁(yè)第一條數(shù)據(jù)的位置,startIndex從0開(kāi)始
          */
          public static int getStartOfPage(int pageNo, int pageSize) {
          return (pageNo - 1) * pageSize;
          }

          /**
          * 設(shè)置總記錄數(shù)
          */
          public void setTotalCount(int totalCount) {
          this.totalCount = totalCount;
          }

          /**
          * 設(shè)置記錄
          * @param results
          */
          public void setResults(List results) {
          this.results = results;
          }

          public void setPageSize(int pageSize) {
          this.pageSize = pageSize;
          }
          }
          @佳佳
          這個(gè)ModelAndView是Spring中的類(lèi),具體可以參考這里: http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/ModelAndView.html
          也可以換成是Struts的實(shí)現(xiàn),這只是用在page和controller之間傳遞參數(shù)用的,和用request是一樣的。
          @迷途羔羊
          排序是要自己寫(xiě)代碼實(shí)現(xiàn)的,所以叫 external paging嘛。
          @fenix
          就靈活性和可擴(kuò)展性來(lái)說(shuō),eXtremeComponents更好一些。
          @佳佳
          你好,我是用的displaytag1.1,應(yīng)該有這兩個(gè)屬性的,或者你重新下載個(gè)displaytag的包看下:
          <attribute>
          <name>partialList</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
          <type>boolean</type>
          <description>enable/disable partialLists. Valid values are true or false</description>
          </attribute>
          <attribute>
          <name>size</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
          <description>
          Used only when partialList=true. Reference to the Integer object containing the size of the total dataset. Can
          be an expression like requestScope.object.property. In the EL version of the taglibrary this must be an EL
          expression which points to the source object.
          </description>
          </attribute>
          @mm

          <h3>前12筆記錄</h3>

          <display:table name="test" length="12">
          <display:column property="id" title="ID" />
          <display:column property="email" />
          <display:column property="status" />
          </display:table>

          可以看看displaytag的例子:http://displaytag.homeip.net/displaytag-examples-1.1/example-subsets.jsp
          re: 運(yùn)用ajax技術(shù)的樹(shù)型菜單 zJun's帛羅閣 2006-07-31 16:37  
          是怎么構(gòu)造樹(shù)的呢?是在tree_ajax.js和tree_htfl.js中嗎?哪里可以找到這兩個(gè)文件呢,這兩個(gè)文件所有的內(nèi)容就是文章中提供的js文件的內(nèi)容嗎?最好能提供這兩個(gè)文件的代碼。現(xiàn)在這樣看有點(diǎn)摸不著頭腦。
          re: 我的第一次面試經(jīng)歷 zJun's帛羅閣 2006-07-19 11:45  
          int ch = 'A' - 1;
          for (int i = 1; i <= 26; i++) {
          for (int j = 1; j <= i; j++) {
          System.out.print((char) (ch + i));
          }
          System.out.println();
          }

          不是很復(fù)雜啊,是題目還有什么要求沒(méi)有寫(xiě)出來(lái)嗎?
          re: 程序員普通的一天8月18日 zJun's帛羅閣 2006-07-18 21:57  
          8月18日? or 7月18日?

          導(dǎo)航

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          統(tǒng)計(jì)

          常用鏈接

          留言簿(15)

          隨筆分類(lèi)

          隨筆檔案

          相冊(cè)

          收藏夾

          博客

          文檔

          站點(diǎn)

          論壇

          搜索

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 土默特左旗| 普安县| 余姚市| 新巴尔虎左旗| 金沙县| 石门县| 和硕县| 普兰县| 西吉县| 竹溪县| 阳谷县| 汉阴县| 黄平县| 台江县| 板桥市| 内丘县| 元朗区| 姜堰市| 灌南县| 曲周县| 西吉县| 洞口县| 新干县| 秀山| 太保市| 贡嘎县| 东平县| 家居| 中山市| 城市| 宾阳县| 出国| 清水河县| 武功县| 台中县| 正蓝旗| 仙游县| 年辖:市辖区| 漯河市| 饶平县| 许昌县|