1    package com.instantbank.collections.main.web;
2    
3    import java.io.Serializable;
4    import javax.servlet.http.HttpServletRequest;
5    
6    public class MenuBean
7        implements Serializable {
8      private HttpServletRequest request;
9    
10   
11     /**
12      * Constructor
13      */
14     public MenuBean() { }
15   
16   
17     private String getBlank() {
18       String result;
19   
20       result = "<td width=\"25%\" align=\"center\" class=\"labelForm\" </td>";
21       return result;
22     }
23   
24   
25     private String getMainRows() {
26       int row = 0;
27       String result = "<tr>";
28   
29       if(request.isUserInRole("CO_Collections")) {
30         result += getOption("CollectorMenu.jsp", "Collector", ++row);
31       }
32       if(request.isUserInRole("CO_Supervisor")) {
33         result += getOption("SupervisorMenu.jsp", "Supervisor", ++row);
34       }
35       if(request.isUserInRole("CO_SystemAdministrator")) {
36         result += getOption("SystemAdministratorMenu.jsp", "System Administrator", ++row);
37       }
38       if(request.isUserInRole("CO_SecurityAdministrator")) {
39         result += getOption("SecurityAdministratorMenu.jsp", "Security Administrator", ++row);
40       }
41       if(request.isUserInRole("CO_Superuser")) {
42         result += getOption("SuperuserMenu.jsp", "Superuser", ++row);
43       }
44       while(row % 4 != 0) {
45         row++;
46         result += getBlank();
47       }
48       result += "</tr>";
49       return result;
50     }
51   
52   
53     private String getOption(String link, String title, int row) {
54       String result = "";
55   
56       if(row % 4 == 1 && row > 1) {
57         result += "</tr><tr>";
58       }
59       result += "<td width=\"25%\" align=\"center\" class=\"labelForm\" style=\"cursor:hand\" ";
60       result += "onMouseOut=\"this.style.backgroundColor='';\" ";
61       result += "onMouseOver=\"this.style.backgroundColor='#C6C7C6';\" ";
62       result += "onClick=\"navigate('" + link + "')\">" + title + "</td>";
63       return result;
64     }
65   
66   
67     public String getRows(String menu, HttpServletRequest request) {
68       this.request = request;
69       if(menu.equals("Main")) {
70         return getMainRows();
71       }
72       return "";
73     }
74   }
75   
76