<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大明白的天地

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      5 隨筆 :: 3 文章 :: 58 評論 :: 0 Trackbacks

    對于以前我寫的兩個分頁標簽,現在存在很多設計不合理和實現的不好的地方。如果有使用的,建議大家廢棄掉
    如果給大家帶來的誤導,表示抱歉。

    希望這個能給大家一些啟發,我信寫得這個標簽,在兩個項目中使用,還是蠻靈活和簡單的。

    代碼及其jar下載:http://m.tkk7.com/Files/qixin000/PagerTag_src.rar
    導入其中的兩個jar即可,源代碼沒有common部分,但是已經是所有的tag源碼了,僅作參考。

    使用方法:

    public class TopicPageData extends AbstractPagerData {
        private ITopicDao topicDao;

        private int categoryId = -1;
        private String keyword = null;
        private int auditId = EAuditStatus.All.getValue();

        public TopicPageData() {
            topicDao = ApplicationContextFactory.getContentFacotry().getTopicDao();
        }

        public IPagerData getPagerData(PagerBean pagerBean) {
            init(pagerBean);
            return new IPagerData() {

                public Object execute(PagerBean pagerBean) {
                    return topicDao.selectTopicByQuery(keyword, categoryId, EAuditStatus.valueOf(auditId), pagerBean.getFrom(), pagerBean.getPageSize());
                }

                public int getTotalCount(PagerBean pagerBean) {
                    return topicDao.selectTopicByQueryCount(keyword, categoryId, EAuditStatus.valueOf(auditId));
                }
            };
        }

        protected void init(PagerBean pagerBean) {
            if (this.getParameterValue(pagerBean, "categoryId") != null)
                categoryId = Integer.parseInt(this.getParameterValue(pagerBean, "categoryId").toString());
            if (this.getParameterValue(pagerBean, "keyword") != null)
                keyword = this.getParameterValue(pagerBean, "keyword").toString();
            if (this.getParameterValue(pagerBean, "auditId") != null)
                auditId = Integer.parseInt(this.getParameterValue(pagerBean, "auditId").toString());

        }
    }


    繼承抽象類AbstractPagerData,實現其中的函數就行了
    init初始化從頁面得到的參數
    getPagerData獲得分頁后的數據函數,它的返回值是一個接口,要用匿名內部類實現該接口
    IPagerData接口有兩個函數要實現,一個是getTotalCount,返回數據總數量,execute返回要顯示的一頁數據。
    然后頁面就能夠得到這些數據了

    頁面的使用方法:

    <%@ taglib prefix="pager" uri="http://www.yushunkeji.cn/taglib" %>
    <pager:pagerData id="topicListId" action="com.yushunkeji.cms.admin.topic.TopicPageData" pageSize="10"
                             dataId="topicList"/>

            <form id="topicListForm" action="cms_topicList.action" method="post">
                <table>
                    <tr>
                        <td>
                            關鍵字<input type="text" name="keyword" id="keyword" value="${param.keyword}"/>
                            分類<select name="categoryId" id="categoryId" onchange="topicListForm.submit();">
                            <option value="-1">請選擇...</option>
                            <c:forEach var="category" items="${categoryList}">
                                <option value="${category.categoryId}" ${param.categoryId==category.categoryId?'selected':''}>${category.categoryTitle}</option>
                            </c:forEach>
                        </select>
                            審核
                            <select name="auditId" id="auditId" onchange="topicListForm.submit();">
                                <option value="-1">所有</option>
                                <option value="0" ${param.auditId==0?"selected":""}>待審核</option>
                                <option value="1" ${param.auditId==1?"selected":""}>已審核</option>
                            </select>
                            <input type="submit" id="query" value="查詢"/>
                            <input type="submit" id="reset" value="重置"
                                   onclick="$('keyword').value='';$('categoryId').value=-1"/><br/>
                        </td>
                    </tr>
                </table>
                <table class="adminlist" cellspacing="1">
                    <thead>
                        <tr>
                            <th width="2%" class="title"><input type="checkbox" onclick="checkAll(this,$('topicListForm'),'selectedId')">
                            </th>
                            <th width="5%" class="title">編號</th>
                            <th class="title">標題</th>
                            <th width="8%" class="title">分類</th>
                            <th width="5%" class="title">作者</th>
                            <th width="4%" class="title">審核</th>
                            <th width="10%" class="title">操作</th>
                        </tr>
                    </thead>
                    <c:forEach var="topic" items="${topicList}">
                        <tr class="row0" onMouseOver="this.className='row1'" onMouseOut="this.className='row0'">
                            <td><input type="checkbox" id="chkTopic" name="selectedId"
                                       value="${topic.topicId}"/></td>
                            <td>${topic.topicId}</td>
                            <td>
                                    <%--<a href="cms_topicTemplate.action?topic.topicId=${topic.topicId}"--%>
                                    <%--target=_blank>${topic.title}</a>--%>
                                <c:choose>
                                    <c:when test="${topic.auditStatus==0}">
                                        <a href="${base}/cms/admin/cms_topicTemplate.action?topic.topicId=${topic.topicId}"
                                           target=_blank>${topic.title}</a>
                                    </c:when>
                                    <c:when test="${topic.auditStatus==1}">
                                        <a href="${base}${topic.htmlFullPath}"
                                           target=_blank>${topic.title}</a>
                                    </c:when>
                                </c:choose>
                            </td>
                            <td>${topic.category.categoryTitle}</td>
                            <td>${topic.author}</td>
                            <td>${topic.auditStatus==1?'通過':'待審'}</td>
                            <td>
                                <c:if test="${ex:isAllowOperation(user,topic.topicId)}">
                                    <a href="#"
                                       onclick="document.popup.show('${base}/cms/admin/cms_referenceTopic.action?topic.topicId=${topic.topicId}', 660, 600, null);">相關</a>
                                    <a href="#"
                                       onclick="window.location.href='cms_topicInfo.action?action=edit&topic.topicId=${topic.topicId}'">編輯</a>
                                    <a href="#" onclick="deleteTopic(${topic.topicId})">刪除</a>
                                </c:if>
                                &nbsp;
                            </td>
                        </tr>
                    </c:forEach>
                    <tfoot>
                        <td colspan="7">
                            <div class="pagination">
                                <pager:pager id="topicListId"/>
                            </div>
                        </td>
                    </tfoot>
                </table>

            </form>

    注意其中的的pager標簽的使用,有兩個一個是pager:pagerData,一個是pager:pager,兩個id要一直,dataid是頁面取數據的對象id,注意foreach循環topicList部分。

    posted on 2007-11-01 14:52 大明白 閱讀(1031) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 久久免费观看国产精品| 久久亚洲AV午夜福利精品一区 | 91禁漫免费进入| 添bbb免费观看高清视频| 亚洲国产精品综合福利专区| 亚洲国产成人久久一区二区三区| 国产亚洲综合一区柠檬导航| 日日麻批免费40分钟日本的| a毛片在线免费观看| 亚洲精品乱码久久久久66| 国产免费爽爽视频免费可以看| 95老司机免费福利| 成全视频在线观看免费| 亚洲伊人久久大香线蕉| 亚洲AV无码乱码在线观看牲色 | 亚洲 日韩 色 图网站| 亚洲精品久久久www| 日本免费高清一本视频| 精品视频在线免费观看| jzzjzz免费观看大片免费| 亚洲午夜精品久久久久久人妖| 毛片视频免费观看| 欧美日韩国产免费一区二区三区| 3d成人免费动漫在线观看| 久久久久久久久久国产精品免费| 人妻在线日韩免费视频| 两个人看的www高清免费观看| 人妻巨大乳hd免费看| 亚洲图片校园春色| 久久久久久亚洲精品成人| 免费一级黄色毛片| 99热在线免费播放| 99久9在线|免费| 亚洲视频免费观看| 亚洲人成免费电影| 全黄大全大色全免费大片| 国产性生大片免费观看性| 亚洲AV永久无码精品放毛片| 亚洲一区二区电影| 久久丫精品国产亚洲av不卡 | 国产午夜免费高清久久影院|