changeset 18:881e7591f3e4

new: adding paginator in books page
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 02 Jun 2015 15:09:54 +0200
parents 372dab740f15
children 9c4937b290c6
files pom.xml src/main/java/de/mpiwg/web/jsp/BooksPage.java src/main/java/de/mpiwg/web/jsp/JSPProxy.java src/main/webapp/componentes/paginator.jsp src/main/webapp/pages/books.jsp src/main/webapp/pages/search.jsp
diffstat 6 files changed, 109 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 					</execution>
 				</executions>
 			</plugin>
-
+			
+			
 		</plugins>
-
+		
 	</build>
-
+			
 </project>
--- 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<String, DBSectionVersion> 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<DBSection>();
+			this.displayBookList = new ArrayList<DBBook>();
 		}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;
+	}
 }
--- 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();
--- 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 @@
 
 <jsp:useBean id="sessionBean" class="de.mpiwg.web.jsp.SessionBean" scope="session" />
 		
-		
+		<% String formName = request.getParameter("formName"); %>
 		
 		<table style="width: 300px; margin-left: auto;margin-right: auto;">
 			<tr>
@@ -10,38 +10,46 @@
 					<input 
 						type="image"
 						src="<%=sessionBean.getApplicationBean().getPaginatorFirst()%>"
-						onclick="setAction('firstPage', 'searchForm');"/>
+						onclick="setAction('firstPage','<%=formName%>');"/>
 				</td>
 				<td>
 					<input 				
 						type="image"
 						src="<%=sessionBean.getApplicationBean().getPaginatorFr()%>"
-						onclick="setAction('fastRewind', 'searchForm');"/>
+						onclick="setAction('fastRewind', '<%=formName%>');"/>
 				</td>
 				<td>
 					<input 				
 						type="image"
 						src="<%=sessionBean.getApplicationBean().getPaginatorPrevious()%>"
-						onclick="setAction('previousPage', 'searchForm');"/>
+						onclick="setAction('previousPage', '<%=formName%>');"/>
 				</td>
-				<td><%=sessionBean.getSearchPage().getPaginator().getRecordStatus()%></td>
+				<td>
+				<% if (formName.equals("booksForm")) { %>
+					<%=sessionBean.getBooksPage().getPaginator().getRecordStatus() %>
+						
+				<% } else if (formName.equals("searchForm")) { %>
+					<%=sessionBean.getSearchPage().getPaginator().getRecordStatus() %>
+					
+				<% } %>
+				</td>
 				<td>
 					<input 				
 						type="image"
 						src="<%=sessionBean.getApplicationBean().getPaginatorNext()%>"
-						onclick="setAction('nextPage', 'searchForm');"/>
+						onclick="setAction('nextPage', '<%=formName%>');"/>
 				</td>
 				<td>
 					<input 				
 						type="image"
 						src="<%=sessionBean.getApplicationBean().getPaginatorFf()%>"
-						onclick="setAction('fastForward', 'searchForm');"/>
+						onclick="setAction('fastForward', '<%=formName%>');"/>
 				</td>
 				<td>
 					<input 	
 						src="<%=sessionBean.getApplicationBean().getPaginatorLast()%>"						
 						type="image"
-						onclick="setAction('lastPage', 'searchForm');"/>
+						onclick="setAction('lastPage', '<%=formName%>');"/>
 				</td>
 			</tr>
 		</table>
\ No newline at end of file
--- 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">
 			<input name="bean" type="hidden" value="booksBean" /> 
 				
-				<table style="width: 90%; margin-left: auto;margin-right: auto;"  class="pageTable">
+				<jsp:include page="../componentes/paginator.jsp">
+					<jsp:param name="formName" value="booksForm"/>
+				</jsp:include> 
+				
+				<table style="width: 90%; margin-left: auto;margin-right: auto;" class="pageTable">
 					<tr>
 					<td>
 						<table class="sortTable">
@@ -151,7 +155,7 @@
 								</tr>
 								<tr>
 									<td>
-										<input type="text" name="level1Filter" value="<%= sessionBean.getBooksPage().getLevel1Filter()%>" size="10"/>
+										<input type="text" name="level1Filter" value="<%= sessionBean.getBooksPage().getLevel1Filter()%>" size="5"/>
 									</td>									
 									<td>
 										<input type="image"
@@ -182,7 +186,7 @@
 								</tr>
 								<tr>
 									<td>
-										<input type="text" name="level2Filter" value="<%= sessionBean.getBooksPage().getLevel2Filter()%>" size="10"/>
+										<input type="text" name="level2Filter" value="<%= sessionBean.getBooksPage().getLevel2Filter()%>" size="5"/>
 									</td>									
 									<td>
 										<input type="image"
@@ -213,7 +217,7 @@
 								</tr>
 								<tr>
 									<td>
-										<input type="text" name="periodFilter" value="<%= sessionBean.getBooksPage().getPeriodFilter()%>" size="10"/>
+										<input type="text" name="periodFilter" value="<%= sessionBean.getBooksPage().getPeriodFilter()%>" size="5"/>
 									</td>									
 									<td>
 										<input type="image"
@@ -244,7 +248,7 @@
 								</tr>
 								<tr>
 									<td>
-										<input type="text" name="dynastyFilter" value="<%= sessionBean.getBooksPage().getDynastyFilter()%>" size="10"/>
+										<input type="text" name="dynastyFilter" value="<%= sessionBean.getBooksPage().getDynastyFilter()%>" size="5"/>
 									</td>									
 									<td>
 										<input type="image"
@@ -275,7 +279,7 @@
 								</tr>
 								<tr>
 									<td>
-										<input type="text" name="adminTypeFilter" value="<%= sessionBean.getBooksPage().getAdminTypeFilter()%>" size="10"/>
+										<input type="text" name="adminTypeFilter" value="<%= sessionBean.getBooksPage().getAdminTypeFilter()%>" size="5"/>
 									</td>									
 									<td>
 										<input type="image"
@@ -311,7 +315,7 @@
 						<td>
 							<table class="sortTable">
 								<tr>
-									<td><label class="tableTitle">TOC Finished
+									<td><label class="tableTitle">TOC Done
 										<input type="image"
 										onclick="setAction('forceReloadBooks', 'booksForm');"
 										src="<%=sessionBean.getApplicationBean().getRefreshImage()%>" width="20" height="20"/>
@@ -417,7 +421,11 @@
 					
 					<% } %>
 				</table>
-
+				
+				<jsp:include page="../componentes/paginator.jsp">
+					<jsp:param name="formName" value="booksForm"/>
+				</jsp:include>
+				
 			</form>
 		<% } %>
 	</div>
--- 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 @@
 			%>
 	
 	
-			<jsp:include page="../componentes/paginator.jsp"/>
+			<jsp:include page="../componentes/paginator.jsp">
+				<jsp:param name="formName" value="searchForm"/>
+			</jsp:include> 
+				
 	
 			<table class="pageTable">
 				<tbody>
@@ -503,8 +506,10 @@
 				</tbody>
 			</table>
 	
-			<jsp:include page="../componentes/paginator.jsp"/>
-	
+			<jsp:include page="../componentes/paginator.jsp">
+				<jsp:param name="formName" value="searchForm"/>
+			</jsp:include> 
+			
 			<%
 				}
 			%>