Source Code Cross Referenced for Controls.java in  » J2EE » Enhydra-Demos » projectmanagement » presentation » payrates » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Demos » projectmanagement.presentation.payrates 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  projectManagement
003:         *
004:         *  Enhydra super-servlet presentation object
005:         *
006:         */
007:
008:        package projectmanagement.presentation.payrates;
009:
010:        import projectmanagement.spec.employee.*;
011:        import projectmanagement.spec.project.*;
012:        import projectmanagement.presentation.*;
013:
014:        import org.w3c.dom.*;
015:        import org.w3c.dom.html.*;
016:
017:        // Enhydra SuperServlet imports
018:        import com.lutris.appserver.server.httpPresentation.HttpPresentation;
019:        import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
020:        import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
021:
022:        // Standard imports
023:        import java.io.IOException;
024:
025:        /**
026:         * Generates the blank HTML page.
027:         */
028:        public class Controls implements  HttpPresentation {
029:
030:            /**
031:             * Constants
032:             */
033:            private static String EMPLOYEE = "employee";
034:            private static String PROJECT = "project";
035:
036:            public void run(HttpPresentationComms comms)
037:                    throws HttpPresentationException, IOException {
038:                ControlsHTML page = new ControlsHTML();
039:
040:                String employee = comms.request.getParameter(EMPLOYEE);
041:                HTMLSelectElement sel = page.getElementCboEmployee();
042:                fillEmployeeSelection(page, sel, employee);
043:
044:                String project = comms.request.getParameter(PROJECT);
045:                sel = page.getElementCboProject();
046:                fillProjectSelection(page, sel, project);
047:
048:                comms.response.writeDOM(page);
049:            }
050:
051:            private void fillEmployeeSelection(ControlsHTML page,
052:                    HTMLSelectElement cboEmployees, String selectedEmployeeID)
053:                    throws ProjectManagementPresentationException {
054:                HTMLOptionElement optEmployee = page.getElementOptEmployee();
055:
056:                try {
057:                    EmployeeManager employeeManager = EmployeeManagerFactory
058:                            .getEmployeeManager("projectmanagement.business.employee.EmployeeManagerImpl");
059:                    Employee[] employees = employeeManager.getAllEmployees();
060:
061:                    // Remove the dummy storyboard text from the prototype HTML
062:                    optEmployee.removeChild(optEmployee.getFirstChild());
063:
064:                    // set the text to select all employees - default option
065:                    HTMLOptionElement clonedOption = (HTMLOptionElement) optEmployee
066:                            .cloneNode(true);
067:                    clonedOption.setValue("");
068:                    String all = "All";
069:                    Node optionTextNode = clonedOption.getOwnerDocument()
070:                            .createTextNode(all);
071:                    clonedOption.appendChild(optionTextNode);
072:                    clonedOption.setAttribute("selected", "selected");
073:
074:                    // Do only a shallow copy of the option as we don't want the text child
075:                    // of the node option
076:                    cboEmployees.appendChild(clonedOption);
077:
078:                    // set all employees
079:                    if (employees != null) {
080:                        for (int i = 0; i < employees.length; i++) {
081:                            Employee e = employees[i];
082:                            // Now populate the combo with employees
083:                            // This algorithm is obscure because options
084:                            // are not normal HTML elements
085:                            // First populate the option value (the employee database ID).
086:                            //  Then append a text child as the option
087:                            // text, which is what is displayed as the text
088:                            // in each row of the select box
089:                            clonedOption = (HTMLOptionElement) optEmployee
090:                                    .cloneNode(true);
091:                            clonedOption.setValue(e.getHandle());
092:                            optionTextNode = clonedOption.getOwnerDocument()
093:                                    .createTextNode(
094:                                            e.getFirstName() + " "
095:                                                    + e.getLastName());
096:                            clonedOption.appendChild(optionTextNode);
097:                            if (selectedEmployeeID != null
098:                                    && e.getHandle().equals(selectedEmployeeID)) {
099:                                clonedOption.setAttribute("selected",
100:                                        "selected");
101:
102:                            }
103:                            // Do only a shallow copy of the option as we don't want the text child
104:                            // of the node option
105:                            cboEmployees.appendChild(clonedOption);
106:                        }
107:                    }
108:                    cboEmployees.removeChild(optEmployee);
109:                } catch (NullPointerException ex) {
110:                } catch (Exception ex) {
111:                    //this.writeDebugMsg("Error populating list of employees: " + ex);
112:                    throw new ProjectManagementPresentationException(
113:                            "Error populating employee list: ", ex);
114:                }
115:
116:            }
117:
118:            private void fillProjectSelection(ControlsHTML page,
119:                    HTMLSelectElement cboProjects, String selectedProjectID)
120:                    throws ProjectManagementPresentationException {
121:                HTMLOptionElement optProject = page.getElementOptProject();
122:
123:                try {
124:
125:                    ProjectManager projectManager = ProjectManagerFactory
126:                            .getProjectManager("projectmanagement.business.project.ProjectManagerImpl");
127:                    Project[] projects = projectManager.getAllProjects();
128:
129:                    // Remove the dummy storyboard text from the prototype HTML
130:                    optProject.removeChild(optProject.getFirstChild());
131:
132:                    // set the text to select all projects - default option
133:                    HTMLOptionElement clonedOption = (HTMLOptionElement) optProject
134:                            .cloneNode(true);
135:                    clonedOption.setValue("");
136:                    String all = "All";
137:                    Node optionTextNode = clonedOption.getOwnerDocument()
138:                            .createTextNode(all);
139:                    clonedOption.appendChild(optionTextNode);
140:                    clonedOption.setAttribute("selected", "selected");
141:
142:                    // Do only a shallow copy of the option as we don't want the text child
143:                    // of the node option
144:                    cboProjects.appendChild(clonedOption);
145:
146:                    // set all projects
147:
148:                    if (projects != null) {
149:                        for (int i = 0; i < projects.length; i++) {
150:                            Project p = projects[i];
151:                            // Now populate the combo with projects
152:                            // This algorithm is obscure because options
153:                            // are not normal HTML elements
154:                            // First populate the option value (the project database ID).
155:                            //  Then append a text child as the option
156:                            // text, which is what is displayed as the text
157:                            // in each row of the select box
158:                            clonedOption = (HTMLOptionElement) optProject
159:                                    .cloneNode(true);
160:                            clonedOption.setValue(p.getHandle());
161:                            optionTextNode = clonedOption.getOwnerDocument()
162:                                    .createTextNode(p.getName());
163:                            clonedOption.appendChild(optionTextNode);
164:                            if (selectedProjectID != null
165:                                    && p.getHandle().equals(selectedProjectID)) {
166:                                clonedOption.setAttribute("selected",
167:                                        "selected");
168:
169:                            }
170:                            // Do only a shallow copy of the option as we don't want the text child
171:                            // of the node option
172:                            cboProjects.appendChild(clonedOption);
173:                        }
174:                    }
175:
176:                    cboProjects.removeChild(optProject);
177:
178:                } catch (NullPointerException ex) {
179:                } catch (Exception ex) {
180:                    //this.writeDebugMsg("Error populating list of projects: " + ex);
181:                    throw new ProjectManagementPresentationException(
182:                            "Error populating project list: ", ex);
183:                }
184:
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.