Esempio n. 1
0
 private StringBuffer nextPage(
     Pagination pagination, String baseUrl, int count, boolean previous) {
   HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
   StringBuffer output = new StringBuffer();
   try {
     Object[] objects = new Object[1];
     objects[0] = new Integer(pagination.getNumResults());
     if (pagination.getOffset() == 0 && previous) {
       output.append(
           Utilities.formatMessage("common.pagination.previous", request.getLocale(), objects));
       return output;
     }
     if (pagination.getNumResults() != count && !previous) {
       output.append(
           Utilities.formatMessage("common.pagination.next", request.getLocale(), objects));
       return output;
     }
     output.append("<a href=\"");
     String virtualWiki = Utilities.getVirtualWikiFromRequest(request);
     WikiLink wikiLink = LinkUtil.parseWikiLink(baseUrl);
     int offset = pagination.getOffset() + pagination.getNumResults();
     if (previous) {
       offset = pagination.getOffset() - pagination.getNumResults();
       if (offset < 0) offset = 0;
     }
     String query =
         LinkUtil.appendQueryParam(
             wikiLink.getQuery(), "num", new Integer(pagination.getNumResults()).toString());
     query += "&amp;offset=" + offset;
     wikiLink.setQuery(query);
     output.append(LinkUtil.buildInternalLinkUrl(request.getContextPath(), virtualWiki, wikiLink));
     output.append("\">");
     if (previous) {
       output.append(
           Utilities.formatMessage("common.pagination.previous", request.getLocale(), objects));
     } else {
       output.append(
           Utilities.formatMessage("common.pagination.next", request.getLocale(), objects));
     }
     output.append("</a>");
   } catch (Exception e) {
     logger.warning("Failure while building pagination element", e);
   }
   return output;
 }
Esempio n. 2
0
 private StringBuffer buildOption(int num, Pagination pagination, String baseUrl) {
   HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
   StringBuffer output = new StringBuffer();
   try {
     if (num == pagination.getNumResults()) {
       output.append(num);
       return output;
     }
     output.append("<a href=\"");
     String virtualWiki = Utilities.getVirtualWikiFromRequest(request);
     WikiLink wikiLink = LinkUtil.parseWikiLink(baseUrl);
     String query =
         LinkUtil.appendQueryParam(wikiLink.getQuery(), "num", new Integer(num).toString());
     query += "&amp;offset=0";
     wikiLink.setQuery(query);
     output.append(LinkUtil.buildInternalLinkUrl(request.getContextPath(), virtualWiki, wikiLink));
     output.append("\">");
     output.append(num);
     output.append("</a>");
   } catch (Exception e) {
     logger.warning("Failure while building pagination element", e);
   }
   return output;
 }