KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > applications > webtalk > controller > DisplayDropCustomerSelectAction


1 /*
2  * DisplayDropCustomerSelectAction.java
3  *
4  */

5
6 package com.quikj.application.communicator.applications.webtalk.controller;
7
8 import com.quikj.application.communicator.applications.webtalk.model.*;
9 import com.quikj.application.communicator.admin.model.*;
10 import com.quikj.application.communicator.admin.controller.*;
11
12 import javax.servlet.http.*;
13 import org.apache.struts.action.*;
14 import org.apache.struts.util.*;
15 import java.sql.*;
16 import java.util.*;
17 import java.io.UnsupportedEncodingException JavaDoc;
18 import java.net.*;
19 /**
20  *
21  * @author bhm
22  */

23 public class DisplayDropCustomerSelectAction extends Action
24 {
25     
26     /** Creates a new instance of DisplayUserManagementAction */
27     public DisplayDropCustomerSelectAction()
28     {
29     }
30     
31     public ActionForward execute(ActionMapping mapping,
32     ActionForm form,
33     HttpServletRequest request,
34     HttpServletResponse response) throws UnsupportedEncodingException JavaDoc
35     {
36         DropCustomerSelectForm cform = (DropCustomerSelectForm)form;
37         ActionErrors errors = new ActionErrors();
38         
39         Connection c = (Connection)request.getSession().getAttribute("connection");
40         if (c == null)
41         {
42             errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.not.logged.in"));
43             saveErrors(request, errors);
44             
45             return mapping.findForward("logon");
46         }
47         
48         AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo");
49         if (element.isAdminLevel() == false)
50         {
51             errors.add(ActionErrors.GLOBAL_ERROR,
52             new ActionError("error.insufficient.privilege"));
53             saveErrors(request, errors);
54             
55             return mapping.findForward("main_menu");
56         }
57         
58         GroupTable groups = new GroupTable();
59         groups.setConnection(c);
60         
61         ArrayList domain_list = groups.listDomains();
62         
63         if (domain_list != null)
64         {
65             ArrayList list = new ArrayList();
66             Iterator iter = domain_list.iterator();
67             
68             while (iter.hasNext() == true)
69             {
70                 String JavaDoc domain = (String JavaDoc)iter.next();
71                 
72                 if (domain.equals("ace") == false)
73                 {
74                     list.add(new LabelValueBean(domain, URLEncoder.encode(domain, "UTF-8")));
75                 }
76             }
77             
78             cform.setDomains(list);
79         }
80         
81         // add related tasks to the navigation bar
82
WebTalkRelatedTasks menu = new WebTalkRelatedTasks();
83         request.setAttribute("menu", menu);
84         
85         menu.addLink(new LinkAttribute("List all groups", "list_groups"));
86         
87         return mapping.getInputForward();
88     }
89 }
90
Popular Tags