# HG changeset patch # User Zoe Hong # Date 1433250594 -7200 # Node ID 881e7591f3e45e23c5b372e11acced2416d4b28f # Parent 372dab740f15478e766e4632b24ead4cda603e86 new: adding paginator in books page diff -r 372dab740f15 -r 881e7591f3e4 pom.xml --- a/pom.xml Tue Jun 02 11:56:45 2015 +0200 +++ b/pom.xml Tue Jun 02 15:09:54 2015 +0200 @@ -202,9 +202,10 @@ - + + - + - + diff -r 372dab740f15 -r 881e7591f3e4 src/main/java/de/mpiwg/web/jsp/BooksPage.java --- a/src/main/java/de/mpiwg/web/jsp/BooksPage.java Tue Jun 02 11:56:45 2015 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/BooksPage.java Tue Jun 02 15:09:54 2015 +0200 @@ -43,6 +43,9 @@ private Map sectionVersionMap = null; private int bookNumber; + private DataPaginator paginator = new DataPaginator(); + + private String tocBookId = new String(); private String bookNameFilter = new String(); @@ -93,10 +96,9 @@ } if(completeBookList.size() > 0){ - //this.searchMessage = completeSectionList.size() + " section(s) found for the term(s): " + this.searchTerm; //this.filteringMessage = this.filteredSectionList.size() + " section(s) listed after the filtering"; - //this.paginator.setCurrentPage(0); - //this.paginator.resetNumberOfPages(filteredSectionList.size()); + this.paginator.setCurrentPage(0); + this.paginator.resetNumberOfPages(filteredBookList.size()); this.updateCurrentBooks(); }else{ //this.searchMessage = "No sections found for the term(s): " + this.searchTerm; @@ -107,29 +109,27 @@ private void updateCurrentBooks() { - this.displayBookList = this.filteredBookList; - /*this.paginator.initCount(); + //this.displayBookList = this.filteredBookList; + // TODO: update displayBookList using paginator + + this.paginator.initCount(); int startRecord = this.paginator.getCurrentPage() * this.paginator.getItemsPerPage(); if(this.paginator.getNumberOfPages() == 0){ - this.displaySectionList = new ArrayList(); + this.displayBookList = new ArrayList(); }else if((this.paginator.getCurrentPage() + 1) == this.paginator.getNumberOfPages()){ - int mod = this.filteredSectionList.size() % paginator.getItemsPerPage(); + int mod = this.filteredBookList.size() % paginator.getItemsPerPage(); if(mod == 0){ - this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); + this.displayBookList = filteredBookList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); }else{ - this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + mod); + this.displayBookList = filteredBookList.subList(startRecord, startRecord + mod); } }else{ - this.displaySectionList = filteredSectionList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); + this.displayBookList = filteredBookList.subList(startRecord, startRecord + this.paginator.getItemsPerPage()); } - for(DBSection section : this.displaySectionList){ - section.setBranches(this.branchesMap.get(section.getId())); - } - */ } @@ -448,7 +448,42 @@ } + public void firstPage() { + this.paginator.first(); + this.updateCurrentBooks(); + } + + public void lastPage() { + this.paginator.last(); + this.updateCurrentBooks(); + } + + public void fastForward() { + this.paginator.fastForward(); + this.updateCurrentBooks(); + } + + public void fastRewind() { + this.paginator.fastRewind(); + this.updateCurrentBooks(); + } + + public void previousPage() { + this.paginator.previous(); + this.updateCurrentBooks(); + } + + public void nextPage() { + this.paginator.next(); + this.updateCurrentBooks(); + } - + public DataPaginator getPaginator() { + return paginator; + } + + public void setPaginator(DataPaginator paginator) { + this.paginator = paginator; + } } diff -r 372dab740f15 -r 881e7591f3e4 src/main/java/de/mpiwg/web/jsp/JSPProxy.java --- a/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Tue Jun 02 11:56:45 2015 +0200 +++ b/src/main/java/de/mpiwg/web/jsp/JSPProxy.java Tue Jun 02 15:09:54 2015 +0200 @@ -160,7 +160,21 @@ getSessionBean().getBooksPage().forceLoadBooks(); } else if(StringUtils.equals(action, "filter")){ getSessionBean().getBooksPage().filter(); - + + //PAGINATOR + } else if(StringUtils.equals(action, "firstPage")){ + getSessionBean().getBooksPage().firstPage(); + } else if(StringUtils.equals(action, "fastRewind")){ + getSessionBean().getBooksPage().fastRewind(); + } else if(StringUtils.equals(action, "previousPage")){ + getSessionBean().getBooksPage().previousPage(); + } else if(StringUtils.equals(action, "nextPage")){ + getSessionBean().getBooksPage().nextPage(); + } else if(StringUtils.equals(action, "fastForward")){ + getSessionBean().getBooksPage().fastForward(); + } else if(StringUtils.equals(action, "lastPage")){ + getSessionBean().getBooksPage().lastPage(); + // Sorting } else if(StringUtils.equals(action, "sortByBookIdUp")){ getSessionBean().getBooksPage().sortByBookIdUp(); diff -r 372dab740f15 -r 881e7591f3e4 src/main/webapp/componentes/paginator.jsp --- a/src/main/webapp/componentes/paginator.jsp Tue Jun 02 11:56:45 2015 +0200 +++ b/src/main/webapp/componentes/paginator.jsp Tue Jun 02 15:09:54 2015 +0200 @@ -2,7 +2,7 @@ - + <% String formName = request.getParameter("formName"); %> @@ -10,38 +10,46 @@ + onclick="setAction('firstPage','<%=formName%>');"/> - +
+ onclick="setAction('fastRewind', '<%=formName%>');"/> + onclick="setAction('previousPage', '<%=formName%>');"/> <%=sessionBean.getSearchPage().getPaginator().getRecordStatus()%> + <% if (formName.equals("booksForm")) { %> + <%=sessionBean.getBooksPage().getPaginator().getRecordStatus() %> + + <% } else if (formName.equals("searchForm")) { %> + <%=sessionBean.getSearchPage().getPaginator().getRecordStatus() %> + + <% } %> + + onclick="setAction('nextPage', '<%=formName%>');"/> + onclick="setAction('fastForward', '<%=formName%>');"/> + onclick="setAction('lastPage', '<%=formName%>');"/>
\ No newline at end of file diff -r 372dab740f15 -r 881e7591f3e4 src/main/webapp/pages/books.jsp --- a/src/main/webapp/pages/books.jsp Tue Jun 02 11:56:45 2015 +0200 +++ b/src/main/webapp/pages/books.jsp Tue Jun 02 15:09:54 2015 +0200 @@ -44,7 +44,11 @@ class="contentForm"> - + + + + +
@@ -151,7 +155,7 @@
- +
- +
- +
- +
- + -
- + + + + + <% } %> diff -r 372dab740f15 -r 881e7591f3e4 src/main/webapp/pages/search.jsp --- a/src/main/webapp/pages/search.jsp Tue Jun 02 11:56:45 2015 +0200 +++ b/src/main/webapp/pages/search.jsp Tue Jun 02 15:09:54 2015 +0200 @@ -216,7 +216,10 @@ %> - + + + + @@ -503,8 +506,10 @@
- - + + + + <% } %>