KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > screens > ModuleSwitchingLink


1 /*
2  * Created on 03.01.2005
3  *
4  * To change the template for this generated file go to
5  * Window - Preferences - Java - Code Generation - Code and Comments
6  */

7 package org.tigris.scarab.screens;
8
9 import java.util.ArrayList JavaDoc;
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 {
27     private RunData data;
28
29     public ModuleSwitchingLink(RunData data)
30     {
31         super();
32         this.data = data;
33         init((Object JavaDoc)data);
34     }
35     
36     /**
37      * override super method and make it public
38      */

39     public TemplateLink setPage(String JavaDoc moduleId)
40     {
41         String JavaDoc homePage = null;
42         try
43         {
44             Module module = ModuleManager
45                 .getInstance(new Integer JavaDoc(moduleId));
46             ScarabUser user = (ScarabUser)data.getUser();
47             homePage = user.getHomePage(module);
48         }
49         catch (Exception JavaDoc e)
50         {
51             Log.get().error("Could not determine homepage", e);
52             homePage = "Index.vm";
53         }
54         TemplateLink link = super.setPage(homePage, moduleId);
55         return link;
56     }
57     
58     /**
59      * Add a key value pair (in the form of a 2 object array) to the provided
60      * list
61      *
62      * @param list List to add to.
63      * @param name A String with the name to add.
64      * @param value A String with the value to add.
65      */

66     protected void addPair(ArrayList JavaDoc list,
67                            String JavaDoc name,
68                            String JavaDoc value)
69     {
70         int hah = 0;
71         Object JavaDoc[] tmp = new Object JavaDoc[2];
72
73         tmp[0] = data.getParameters().convertAndTrim(name);
74         tmp[1] = value;
75
76         list.add(tmp);
77     }
78     
79 }
80
81
Popular Tags