1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.ginp.commands;
20
21 import java.util.Vector;
22
23 import net.sf.ginp.CommandParameter;
24 import net.sf.ginp.GinpModel;
25 import net.sf.ginp.config.Configuration;
26
27 /**
28 * Select the current collection and folder position.
29 *
30 *@author Doug Culnane
31 *@version $Revision: 264 $
32 */
33 public class ViewPage implements Command {
34
35 /**
36 * PicCollection id (colid) and path (path) should be sent in the parameters
37 * so that the model is not out of sync with browser. This can happen due
38 * to use of the Back Button.
39 *
40 *@param model Description of the Parameter
41 *@param params Description of the Parameter
42 */
43 public void action(GinpModel model, Vector params) {
44
45 String page = "first";
46
47
48 for (int i = 0; i < params.size(); i++) {
49 CommandParameter param = (CommandParameter) params.get(i);
50 if (param.getName().equals("page")) {
51 page = param.getValue();
52 }
53 }
54
55 if (page.equals("first")) {
56 model.setPageOffset(0);
57 model.setPagePosition(0);
58 } else if (page.equals("prev")) {
59 model.setPageOffset(-2);
60 } else if (page.equals("next")) {
61 model.setPageOffset(0);
62 } else if (page.equals("last")) {
63 model.setPageOffset(-1);
64 model.setPagePosition(model.getCollection().getPictureLength());
65 }
66 model.setCurrentPage(Configuration.getCollectionPageName());
67 }
68 }
69