Newer
Older
TalkjaSolr / web / WEB-INF / jsp / _pagination.jsp
@haya4 haya4 on 17 Mar 2019 1 KB 1st
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<div id="page">
<%
String p_head = "|&lt;&lt;先頭ページへ";
String p_prev = "&lt;前へ";
String p_next = "次へ&gt;";
String p_tail = "末尾ページへ&gt;&gt;|";

int wsiz = 10;
int w1 = 5;
int w2 = 5;

int pcnt = (int)(found / rows + ( ( found % rows ) == 0 ? 0 : 1 ));
int cpag = (int)(start / rows + 1);
int wbgn = cpag - w1;
int wend = cpag + w2;
if( wbgn < 1 ){
  wbgn = 1;
  wend = wbgn + wsiz;
  if( wend > pcnt + 1 ){
    wend = pcnt + 1;
  }
}
if( wend > pcnt + 1 ){
  wend = pcnt + 1;
  wbgn = wend - wsiz;
  if( wbgn < 1 ){
    wbgn = 1;
  }
}
%>
<% if( pcnt > 1 ){ %>
<strong>Page</strong>
  <% if( cpag > 1 ){ %>
    <a href="./index.html<%=SearchUtil.getLinkStr(query,fq, null, 0)%>"><%=p_head%></a>&nbsp;&nbsp;&nbsp;
    <a href="./index.html<%=SearchUtil.getLinkStr(query,fq, null, ((cpag-2)*rows))%>"><%=p_prev%></a>&nbsp;&nbsp;&nbsp;
  <% } %>
  &nbsp;
  <% for(int i=wbgn;i<wend;i++){ %>
    <% if(cpag == i){ %>
      <%=i %>&nbsp;&nbsp;&nbsp;
    <% }else{ %>
      <a href="./index.html<%=SearchUtil.getLinkStr(query,fq, null, ((i-1)*rows))%>"><%=i %></a>&nbsp;&nbsp;&nbsp;
    <% } %>
  <% } %>
  &nbsp;
  <% if( cpag < pcnt ){ %>
    <a href="./index.html<%=SearchUtil.getLinkStr(query,fq, null, (cpag*rows))%>"><%=p_next%></a>&nbsp;&nbsp;&nbsp;
    <a href="./index.html<%=SearchUtil.getLinkStr(query,fq, null, ((pcnt-1)*rows))%>"><%=p_tail%></a>&nbsp;&nbsp;&nbsp;
  <% } %>
<% } %>
</div>