-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowLotsStrategy.java
More file actions
33 lines (24 loc) · 1.05 KB
/
Copy pathShowLotsStrategy.java
File metadata and controls
33 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.example.cw.controllers.Strats;
import com.example.cw.services.LotService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import static java.util.Objects.isNull;
public class ShowLotsStrategy extends SomeStrat {
LotService lotService;
public ShowLotsStrategy(LotService lotService) {
this.lotService = lotService;
}
@Override
public void execGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int pageNumber = 1;
if (!isNull(request.getParameter("pageNumber"))) {
pageNumber = Integer.parseInt(request.getParameter("pageNumber"));
}
request.setAttribute("lots", lotService.getActiveLots(pageNumber, sizeLimit));
request.setAttribute("pageNumber", pageNumber);
request.setAttribute("numberOfPages", getPageCount(lotService.getSumOfRecords()));
forwardToJsp(request, response, "AllLots");
}
}