Package com.freewebsys.core.page

Examples of com.freewebsys.core.page.PageConf


    try {
      if (total <= limit) {// 如果还不够一页 就不显示
        return super.doEndTag();
      }
      // 初始化参数.每次独立计算.否则分页有问题.
      PageConf pageConf = new PageConf(start, limit, total);
      String ctx = pageContext.getServletContext().getContextPath() + "/";
      //ctx += action + findOtherValue();
      if (action.indexOf("?") >= 0) {// 如果存在?号用&
        ctx += action + "&" + findOtherValue();
      } else {// 否则用?
        ctx += action + "?" + findOtherValue();
      }
      PageConf pageConfFirst = new PageConf(start, limit, total);
      String firstUrl = ctx;
      PageConf pageConfPrev = new PageConf(start, limit, total);
      String prevUrl = ctx;
      PageConf pageConfNext = new PageConf(start, limit, total);
      String nextUrl = ctx;
      PageConf pageConfLast = new PageConf(start, limit, total);
      String lastUrl = ctx;

      if (pageConf.hasPrevious()) {
        pageConfFirst.getFirst();
        firstUrl += "&start=" + pageConfFirst.getStart();
        // firstUrl += "-start~" + pageConfFirst.getStart();
        pageConfPrev.getPrevious();
        prevUrl += "&start=" + pageConfPrev.getStart();
        // prevUrl += "-start~" + pageConfPrev.getStart();
      }
      if (pageConf.hasNext()) {
        pageConfNext.getNext();
        nextUrl += "&start=" + pageConfNext.getStart();
        // nextUrl += "-start~" + pageConfNext.getStart();
        pageConfLast.getLast();
        lastUrl += "&start=" + pageConfLast.getStart();
        // lastUrl += "-start~" + pageConfLast.getStart();
      }
      // 直接将数据写到页面
      String str = genCenterButtons(start, limit, total, ctx);
      if (theme == null || theme.equals("")) {
View Full Code Here


   * 生成多个跳转按钮方法,如1,2,3,4,5这样的按钮跳转最大7页跳转
   */
  private String genCenterButtons(int start, int limit, int total, String ctx) {

    // 初始化参数.每次独立计算.否则分页有问题.
    PageConf pageConf = new PageConf(start, limit, total);
    PageConf pageConfTemp1 = new PageConf(start, limit, total);
    PageConf pageConfTemp2 = new PageConf(start, limit, total);

    // 结束页
    PageConf pageConfTempLast = new PageConf(start, limit, total);
    //
    pageConfTempLast.getLast();
    // 字符串拼写.
    StringBuilder strOut = new StringBuilder();
    // 设置开始为当前页往前3页,最小1
    int begin = Math.max(1, (pageConf.getCurrentPage() + 1) - 3);
    // 设置结束为当前页往后3页,最大到总页数
    int end = Math.min((pageConf.getCurrentPage() + 1) + 3,
        pageConf.getTotalPage());
    int abs = 5 - Math.abs(pageConfTempLast.getCurrentPage()
        - pageConf.getCurrentPage());
    if (abs > 0) {
      begin = pageConf.getCurrentPage() - abs;
      begin = Math.min(begin, (pageConf.getCurrentPage() + 1) - 3);
      begin = Math.max(1, begin);
    }
    // 计算当前页和首页的距离
    abs = 7 - pageConf.getCurrentPage();
    if (abs > 0) {
      end = pageConf.getCurrentPage() + abs;
      end = Math.max((pageConf.getCurrentPage() + 1) + 3, end);
      end = Math.min(end, pageConf.getTotalPage());
    }

    if (pageConf.getTotalPage() > 7) {// 如果大于7显示首页末页
      // 显示前一页
      if (pageConfTemp1.hasPrevious()) {
        pageConfTemp1.getPrevious();
        strOut.append(PAGE_A + ctx + "&start="
            + pageConfTemp1.getStart() + "');\">");
        strOut.append("上一页</a>");
      }

      if (pageConf.getCurrentPage() > 3) {
        // 显示第 1
        strOut.append(PAGE_A + ctx + "&start=" + (0) + "');\">");
        strOut.append(1);
        strOut.append("</a>");
        if (pageConf.getCurrentPage() > 4) {
          // 显示第 2 页
          strOut.append(PAGE_A + ctx + "&start="
              + (0 + pageConf.getLimit()) + "');\">");
          strOut.append(2);
          strOut.append("</a>");
        }
        strOut.append("…");
      }
    }
    // if(pageConf.getCurrentPage())
    // 循环显示数字
    for (int i = begin; i <= end; i++) {
      // 循环多个table的button
      int startTemp = (i - 1) * pageConf.getLimit();
      if (i == (pageConf.getCurrentPage() + 1)) {
        strOut.append("<span class='current'>");
        strOut.append(i);// 当前页显示禁用
        strOut.append("</span>");
      } else {
        strOut.append(PAGE_A + ctx + "&start=" + startTemp + "');\">");
        strOut.append(i);
        strOut.append("</a>");
      }
    }
    // 末页显示,显示最后一页和倒数第二页
    if (pageConf.getTotalPage() > 7) {// 如果大于7显示首页末页

      if (pageConf.getCurrentPage() < (pageConfTempLast.getCurrentPage() - 3)) {
        // 如果当前页是倒数第4页就不显示
        strOut.append("…");
        // System.out.println(pageConf.getCurrentPage() + "/"
        // + pageConfTempLast.getCurrentPage());
        if (pageConf.getCurrentPage() < (pageConfTempLast
            .getCurrentPage() - 4)) {
          // 如果当前页是倒数第4页就不显示倒数第2页
          strOut.append(PAGE_A
              + ctx
              + "&start="
              + (pageConfTempLast.getStart() - pageConf
                  .getLimit()) + "');\">");
          strOut.append(pageConfTempLast.getCurrentPage());
          strOut.append("</a>");
        }
        strOut.append(PAGE_A + ctx + "&start="
            + pageConfTempLast.getStart() + "');\">");
        strOut.append(pageConfTempLast.getCurrentPage() + 1);
        strOut.append("</a>");
      }
      // 显示下一页
      if (pageConfTemp2.hasNext()) {
        pageConfTemp2.getNext();
View Full Code Here

      String hql = " select module from UserInfo module ";
      // 通用查询匹配
      Object[] values = CommonDaoUtil.commonQuery(map);
      hql += values[0].toString();
      // Object[]需要进行强制转换.
      PageConf pageConf = baseDao.findPage(start, limit, hql,
          (Object[]) values[1]);
      if (pageConf != null && pageConf.getData() != null) {
        List list = pageConf.getData();
        for (int i = 0; i < list.size(); i++) {
          UserInfo friendUser = (UserInfo) list.get(i);
          System.out.println(userInfo.getId() + "/"
              + friendUser.getId());
          String hql_2 = "select friend.status from Friend friend where friend.userId = ? and friend.friend.id = ? ";
View Full Code Here

  @Override
  @Transactional
  public PageConf findFeedPiecePageList(int start, int limit,
      UserInfo userInfo, String type) throws FeedException {
    try {
      PageConf conf = null;
      if (type != null && !type.equals("all")) {
        String hql = " select module from FeedUser module left join fetch module.feed where module.userId = ? and module.feedType = ? ";
        // 通用查询匹配
        conf = baseDao.findPage(start, limit, hql, userInfo.getId(),
            type);
View Full Code Here

      // 参数
      Map values = new HashMap();
      values.put("parameters", this);

      // 初始化参数.每次独立计算.否则分页有问题.
      PageConf pageConf = new PageConf(start, limit, total);
      values.put("pageConf", pageConf);
      String ctx = pageContext.getServletContext().getContextPath() + "/";
      ctx += action;
      if (action.indexOf("?") >= 0) {// 如果存在?号用&
        ctx += "&" + findOtherValue();
      } else {// 否则用?
        ctx += "?" + findOtherValue();
      }
      PageConf pageConfFirst = new PageConf(start, limit, total);
      String firstUrl = ctx;
      PageConf pageConfPrev = new PageConf(start, limit, total);
      String prevUrl = ctx;
      PageConf pageConfNext = new PageConf(start, limit, total);
      String nextUrl = ctx;
      PageConf pageConfLast = new PageConf(start, limit, total);
      String lastUrl = ctx;
      // pageContext.setAttribute("gridPanelWidth", width);
      // pageContext.setAttribute("gridPanelHeight", height);
      if (pageConf.hasPrevious()) {
        pageConfFirst.getFirst();
        firstUrl += "&start=" + pageConfFirst.getStart();
        pageConfPrev.getPrevious();
        prevUrl += "&start=" + pageConfPrev.getStart();
      }
      if (pageConf.hasNext()) {
        pageConfNext.getNext();
        nextUrl += "&start=" + pageConfNext.getStart();
        pageConfLast.getLast();
        lastUrl += "&start=" + pageConfLast.getStart();
      }
      // 设置分页url.
      values.put("baseUrl", ctx);
      values.put("firstUrl", firstUrl);
      values.put("prevUrl", prevUrl);
View Full Code Here

      // 参数
      Map values = new HashMap();
      values.put("parameters", this);

      // 初始化参数.每次独立计算.否则分页有问题.
      PageConf pageConf = new PageConf(start, limit, total);
      values.put("pageConf", pageConf);
      String ctx = pageContext.getServletContext().getContextPath() + "/";
      ctx += action;
      if (action.indexOf("?") >= 0) {// 如果存在?号用&
        ctx += "&" + findOtherValue();
      } else {// 否则用?
        ctx += "?" + findOtherValue();
      }
      PageConf pageConfFirst = new PageConf(start, limit, total);
      String firstUrl = ctx;
      PageConf pageConfPrev = new PageConf(start, limit, total);
      String prevUrl = ctx;
      PageConf pageConfNext = new PageConf(start, limit, total);
      String nextUrl = ctx;
      PageConf pageConfLast = new PageConf(start, limit, total);
      String lastUrl = ctx;
      // pageContext.setAttribute("gridPanelWidth", width);
      // pageContext.setAttribute("gridPanelHeight", height);
      if (pageConf.hasPrevious()) {
        pageConfFirst.getFirst();
        firstUrl += "&start=" + pageConfFirst.getStart();
        pageConfPrev.getPrevious();
        prevUrl += "&start=" + pageConfPrev.getStart();
      }
      if (pageConf.hasNext()) {
        pageConfNext.getNext();
        nextUrl += "&start=" + pageConfNext.getStart();
        pageConfLast.getLast();
        lastUrl += "&start=" + pageConfLast.getStart();
      }
      // 设置分页url.
      values.put("baseUrl", ctx);
      values.put("firstUrl", firstUrl);
      values.put("prevUrl", prevUrl);
View Full Code Here

  @Override
  public int doStartTag() throws JspException {
    try {
      // 初始化参数.每次独立计算.否则分页有问题.
      PageConf pageConf = new PageConf(start, limit, total);
      String ctx = pageContext.getServletContext().getContextPath() + "/";
      if (action.indexOf("?") >= 0) {// 如果存在?号用&
        ctx += action + "&" + findOtherValue();
      } else {// 否则用?
        ctx += action + "?" + findOtherValue();
      }
      boolean hasPrev = false;
      boolean hasNext = false;
      PageConf pageConfPrev = new PageConf(start, limit, total);
      String prevUrl = ctx;
      PageConf pageConfNext = new PageConf(start, limit, total);
      String nextUrl = ctx;

      if (pageConf.hasPrevious()) {
        hasPrev = true;
        pageConfPrev.getPrevious();
        prevUrl += "&start=" + pageConfPrev.getStart();
      }
      if (pageConf.hasNext()) {
        hasNext = true;
        pageConfNext.getNext();
        nextUrl += "&start=" + pageConfNext.getStart();
      }
      pageContext.setAttribute("hasPrev", hasPrev);
      pageContext.setAttribute("hasNext", hasNext);
      pageContext.setAttribute("prevUrl", prevUrl);
      pageContext.setAttribute("nextUrl", nextUrl);
View Full Code Here

          + removeSelect(removeOrders(hql));
      // 查询总数
      int total = ((Long) findFirstOne(countQueryString, values))
          .intValue();
      // System.out.println("page size:" + total);
      PageConf pageConf = new PageConf(start, limit, total);
      if (start >= total) {// 如果跳转的页数超出总页数跳到最后一页
        pageConf.getLast();
      }
      if (start <= 0) {// 如果跳转的页数为负数或0,跳转到首页
        pageConf.getFirst();
      }
      Query query = createQuery(hql, values);
      List list = query.setFirstResult((int) pageConf.getStart())
          .setMaxResults((int) pageConf.getLimit()).list();
      // 将数据放到pageConf
      pageConf.setData(list);
      return pageConf;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

TOP

Related Classes of com.freewebsys.core.page.PageConf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.