01: /*
02: * Created on 03.01.2005
03: *
04: * To change the template for this generated file go to
05: * Window - Preferences - Java - Code Generation - Code and Comments
06: */
07: package org.tigris.scarab.screens;
08:
09: import java.util.ArrayList;
10:
11: import org.apache.turbine.RunData;
12: import org.apache.turbine.tool.TemplateLink;
13: import org.tigris.scarab.om.Module;
14: import org.tigris.scarab.om.ModuleManager;
15: import org.tigris.scarab.om.ScarabUser;
16: import org.tigris.scarab.util.Log;
17: import org.tigris.scarab.util.ScarabLink;
18:
19: /**
20: * @author hdab
21: *
22: * To change the template for this generated type comment go to
23: * Window - Preferences - Java - Code Generation - Code and Comments
24: */
25: public class ModuleSwitchingLink extends ScarabLink {
26: private RunData data;
27:
28: public ModuleSwitchingLink(RunData data) {
29: super ();
30: this .data = data;
31: init((Object) data);
32: }
33:
34: /**
35: * override super method and make it public
36: */
37: public TemplateLink setPage(String moduleId) {
38: String homePage = null;
39: try {
40: Module module = ModuleManager.getInstance(new Integer(
41: moduleId));
42: ScarabUser user = (ScarabUser) data.getUser();
43: homePage = user.getHomePage(module);
44: } catch (Exception e) {
45: Log.get().error("Could not determine homepage", e);
46: homePage = "Index.vm";
47: }
48: TemplateLink link = super .setPage(homePage, moduleId);
49: return link;
50: }
51:
52: /**
53: * Add a key value pair (in the form of a 2 object array) to the provided
54: * list
55: *
56: * @param list List to add to.
57: * @param name A String with the name to add.
58: * @param value A String with the value to add.
59: */
60: protected void addPair(ArrayList list, String name, String value) {
61: int hah = 0;
62: Object[] tmp = new Object[2];
63:
64: tmp[0] = data.getParameters().convertAndTrim(name);
65: tmp[1] = value;
66:
67: list.add(tmp);
68: }
69:
70: }
|