KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > projectmanagement > presentation > payrates > Administering


1 package projectmanagement.presentation.payrates;
2
3 import projectmanagement.presentation.*;
4 import projectmanagement.spec.timewage.*;
5 import projectmanagement.spec.project.*;
6
7 import com.lutris.appserver.server.httpPresentation.*;
8 import org.enhydra.xml.xmlc.XMLObject;
9
10 import org.w3c.dom.*;
11 import org.w3c.dom.html.*;
12
13 /**
14  * Shows a list of pay rates to administer.
15  *
16  * @author Sasa Bojanic
17  * @version 1.0
18  */

19 public class Administering extends BasePO {
20
21    /**
22     * Constants
23     */

24    private static String JavaDoc EMPLOYEE = "employee";
25    private static String JavaDoc PROJECT = "project";
26
27
28    /**
29     * Superclass method override. Returns 2.
30     */

31    protected int getRequiredAuthLevel() {
32       return 2;
33    }
34
35    /**
36     * Default event. Just show the page.
37     */

38    public XMLObject handleDefault()
39          throws HttpPresentationException {
40
41        AdministeringHTML page = new AdministeringHTML();
42   try {
43       String JavaDoc employee = this.getComms().request.getParameter(EMPLOYEE);
44       if (employee!=null && employee.length()==0) {
45          employee=null;
46       }
47       String JavaDoc project = this.getComms().request.getParameter(PROJECT);
48       if (project!=null && project.length()==0) {
49          project=null;
50       }
51
52       String JavaDoc errorMsg = this.getSessionData().getAndClearUserMessage();
53       /*if(null != errorMsg) {
54          page.setTextLblErrorText(errorMsg);
55       } else {
56          page.getElementLblErrorText().getParentNode().removeChild(page.getElementLblErrorText());
57       }*/

58    
59     PayRateManager payRateManager = PayRateManagerFactory.
60           getPayRateManager("projectmanagement.business.timewage.PayRateManagerImpl");
61           PayRate[] payRates=payRateManager.getAllPayRatesForEmployeeProjectPair(employee,project);
62   
63        // fetches the table element from HTML document
64
HTMLTableElement table = page.getElementTblPayRates();
65      
66          if (payRates!=null) {
67             for (int i=0; i<payRates.length; i++) {
68                // creating row in HTML table which describes table properties
69
HTMLTableRowElement htmlRE=createNewRow(page,payRates[i]);
70                // appending row at the end of table
71
table.appendChild(htmlRE);
72             }
73          }
74       
75       //Remove template selection row from table
76
table.removeChild(page.getElementTemplateRow());
77       
78 /* Catch Null pointer exception ( we canot make a instances of classes from business layer when we run ProjectManagement_pres )
79  * We need to allow ProjectManagement_pres to be functional , response
80  * will be default HTML page
81  */

82       } catch(NullPointerException JavaDoc ex) {
83            
84       } catch(Exception JavaDoc ex) {
85          this.writeDebugMsg("Error populating list of pay rates: " + ex);
86          throw new ProjectManagementPresentationException("Error getting list of pay rates: ", ex);
87       }
88
89
90       // write out HTML
91
return page;
92    }
93
94    /**
95    * Creates the new row of HTML table element, based on given parameters.
96    */

97    private HTMLTableRowElement createNewRow(AdministeringHTML administeringHTML,
98          PayRate payRate) {
99
100       String JavaDoc payRateID="";
101
102       try {
103          payRateID=payRate.getHandle();
104          administeringHTML.setTextTxtEmployee(payRate.getEmployee().getFirstName()+" "+
105             payRate.getEmployee().getLastName());
106          administeringHTML.setTextTxtProject(payRate.getProject().getName());
107          administeringHTML.setTextTxtPayRate(String.valueOf(payRate.getRate()));
108          administeringHTML.setTextTxtValidFrom(payRate.getValidFrom().toString());
109       } catch (Exception JavaDoc ex) {}
110
111       // image to get details on pay rate
112
HTMLImageElement detailsImg=administeringHTML.getElementImgDetails();
113       detailsImg.setName(payRateID);
114
115       // image to modify pay rate information
116
HTMLImageElement modifyImg=administeringHTML.getElementImgModify();
117       modifyImg.setName(payRateID);
118
119       // image to delete pay rate
120
HTMLImageElement deleteImg=administeringHTML.getElementImgDelete();
121       deleteImg.setName(payRateID);
122
123       HTMLTableRowElement row=(HTMLTableRowElement)administeringHTML.
124          getElementTemplateRow().cloneNode(true);
125
126       return row;
127    }
128
129 }
130
131
Popular Tags