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 * Command to change the model state to display a particular picture.
31 *
32 * @author Doug Culnane
33 * @version $Revision: 303 $
34 */
35 public class ShowPicture implements Command {
36
37 private Log log = LogFactory.getLog(ShowPicture.class);
38
39 /**
40 * PicCollection id (colid) and path (path) should be sent in the parameters
41 * so that the model is not out of sync with browser. This can happen due
42 * to use of the Back Button.
43 *
44 * @param model Description of the Parameter
45 * @param params Description of the Parameter
46 */
47 public void action(GinpModel model, Vector params) {
48
49 String name = "";
50 String path = null;
51
52 for (int i = 0; i < params.size(); i++) {
53 CommandParameter param = (CommandParameter) params.get(i);
54 if (param.getName().equals("name")) {
55 name = param.getValue();
56 } else if (param.getName().equals("colid")) {
57 try {
58 int id = (new Integer(param.getValue())).intValue();
59 model.setCurrectCollection(id);
60 } catch (Exception ex) {
61 log.error(ex);
62 }
63 } else if (param.getName().equals("path")) {
64 path = param.getValue();
65 }
66 }
67 if (path != null) {
68 model.getCollection().setPath(path);
69 }
70 model.setCurrentPage(Configuration.getPicturePageName() + "?name=" + name);
71 }
72 }
73