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 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 /**
30 * Class to action the request changing the current collection.
31 *
32 *@author Doug Culnane
33 *@version $Revision: 303 $
34 */
35 public class SelectCollection implements Command {
36
37 private Log log = LogFactory.getLog(SelectCollection.class);
38
39 /**
40 * Description of the Method
41 *
42 *@param model Description of the Parameter
43 *@param params Description of the Parameter
44 */
45 public void action(GinpModel model, Vector params) {
46
47 String id = "";
48
49 for (int i = 0; i < params.size(); i++) {
50 CommandParameter param = (CommandParameter) params.get(i);
51 if (param.getName().equals("id")) {
52 id = param.getValue();
53 }
54 }
55 int idNum = 0;
56 try {
57 idNum = (new Integer(id)).intValue();
58 } catch (Exception ex) {
59 log.error(ex);
60 idNum = 0;
61 }
62 if (model.setCurrectCollection(idNum)) {
63 model.setCurrentPage(Configuration.getCollectionPageName());
64 model.getCollection().setPath("/");
65 model.setPageOffset(0);
66 model.setPagePosition(0);
67 }
68 }
69 }
70