1 package projectmanagement.presentation.customers; 2 3 import projectmanagement.presentation.*; 4 import projectmanagement.spec.customer.*; 5 import com.lutris.appserver.server.httpPresentation.*; 6 import org.enhydra.xml.xmlc.XMLObject; 7 8 import org.w3c.dom.*; 9 import org.w3c.dom.html.*; 10 11 17 public class Administering extends BasePO { 18 19 22 protected int getRequiredAuthLevel() { 23 return 2; 24 } 25 26 29 public XMLObject handleDefault() 30 throws HttpPresentationException { 31 32 AdministeringHTML page = new AdministeringHTML(); 33 34 String errorMsg = this.getSessionData().getAndClearUserMessage(); 35 40 41 42 try { 43 44 CustomerManager customerManager = CustomerManagerFactory.getCustomerManager("projectmanagement.business.customer.CustomerManagerImpl"); 45 Customer[] customers = customerManager.getAllCustomers(); 46 47 48 HTMLTableElement table = page.getElementTblCustomers(); 50 51 52 if (customers!=null) { 53 for (int i=0; i<customers.length; i++) { 54 HTMLTableRowElement htmlRE=createNewRow(page,customers[i]); 56 table.appendChild(htmlRE); 58 } 59 } 60 table.removeChild(page.getElementTemplateRow()); 62 63 64 69 } catch(NullPointerException ex) { 70 } catch(Exception ex) { 71 this.writeDebugMsg("Error populating list of customers: " + ex); 72 throw new ProjectManagementPresentationException("Error getting list of customers: ", ex); 73 } 74 75 76 77 return page; 79 } 80 81 84 private HTMLTableRowElement createNewRow(AdministeringHTML administeringHTML, 85 Customer customer) { 86 87 String customerID=""; 88 89 try { 90 customerID=customer.getHandle(); 91 administeringHTML.setTextTxtCompanyName(customer.getCompanyName()); 92 administeringHTML.setTextTxtContactName(customer.getContactName()); 93 administeringHTML.setTextTxtPhone(customer.getPhone()); 94 administeringHTML.setTextTxtEmail(customer.getEmail()); 95 } catch (Exception ex) {} 96 97 HTMLImageElement detailsImg=administeringHTML.getElementImgDetails(); 99 detailsImg.setName(customerID); 100 101 HTMLImageElement modifyImg=administeringHTML.getElementImgModify(); 103 modifyImg.setName(customerID); 104 105 HTMLImageElement deleteImg=administeringHTML.getElementImgDelete(); 107 deleteImg.setName(customerID); 108 109 HTMLImageElement projectImg=administeringHTML.getElementImgProject(); 111 projectImg.setName(customerID); 112 113 HTMLTableRowElement row=(HTMLTableRowElement)administeringHTML. 114 getElementTemplateRow().cloneNode(true); 115 116 return row; 117 } 118 119 } 120 121 | Popular Tags |