1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.fhw.cabaweb.webfrontend.tools;
20
21 import javax.servlet.http.HttpServletRequest;
22
23 /***
24 * Diese Klasse enthält einige allgemeine Methoden für das Webfrontend.
25 *
26 * @author <a href="mailto:thomas.vogt@tvc-software.com">Thomas Vogt</a>
27 * @version Version 1.0 29.07.2004
28 */
29 public final class Common
30 {
31
32 /***
33 * Schreibt OffsetWErte in den Request um eine Pager zu erzeugen.
34 *
35 * @param request Der Request
36 * @param size Die Listengrösse
37 */
38 public final static void Pager(HttpServletRequest request, int size)
39 {
40 int offset;
41 int length = 25;
42 String pageOffset = request.getParameter("offset");
43
44 if (pageOffset == null || pageOffset.equals(""))
45 {
46 offset = 0;
47 }
48 else
49 {
50 offset = Integer.parseInt(pageOffset);
51 }
52
53 request.setAttribute("offset", new Integer(offset));
54 if ((offset - length) >= 0)
55 {
56 request.setAttribute("offsetL", new Integer(offset - length));
57 }
58 else
59 request.setAttribute("offsetL", null);
60
61 if ((offset + length) <= size)
62 {
63 request.setAttribute("offsetM", new Integer(offset + length));
64 }
65 else
66 request.setAttribute("offsetM", null);
67
68 request.setAttribute("length", new Integer(length));
69 }
70 }