KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > presentation > customer > AccountHistory


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: AccountHistory.java,v 1.1 2004/08/16 09:33:18 slobodan Exp $
18  */

19
20 package com.lutris.airsent.presentation.customer;
21
22 import com.lutris.appserver.server.httpPresentation.*;
23 import com.lutris.appserver.server.session.*;
24 import com.lutris.util.*;
25 //import com.lutris.xml.xmlc.*;
26
//import com.lutris.xml.xmlc.html.*;
27
import org.w3c.dom.*;
28 import org.w3c.dom.html.*;
29 import org.enhydra.xml.xmlc.XMLObject;
30 import java.util.*;
31 import com.lutris.airsent.presentation.AirSentPresentationException;
32 import com.lutris.airsent.presentation.AirSentConstants;
33 import com.lutris.airsent.presentation.BasePO;
34 import com.lutris.airsent.spec.delivery.Delivery;
35 import com.lutris.airsent.spec.customer.*;
36 /**
37  * AccountHistory.java displays a customers past deliveries
38  * and allows them to select on to prepopulate a future
39  * delivery.
40  */

41 public class AccountHistory extends BasePO {
42
43     /**
44      * Constants
45      */

46     private static final int AUTH_LEVEL = AirSentConstants.CUSTOMER_USER;
47
48     /**
49      * Superclass method override.
50      * returns the authorization level necessary to access this po.
51      *
52      * @return int required authorization level
53      */

54     public int getRequiredAuthLevel() {
55     return AUTH_LEVEL;
56     }
57
58     /**
59      * Default event. Just show the page.
60      */

61     public XMLObject handleDefault() throws HttpPresentationException {
62     return showPage(null, null);
63     }
64
65     /**
66      * Shows the AccountHistory page
67      * @param error messages
68      * @return the page
69      */

70     public XMLObject showPage(String JavaDoc errorMsg, Delivery delivery)
71         throws HttpPresentationException {
72     AccountHistoryHTML page =
73         (AccountHistoryHTML) myComms.xmlcFactory.create(AccountHistoryHTML.class);
74
75     
76     try {
77         
78         Delivery[] deliveries =
79         getApplication().getHomeManager().getDeliveryManager().findByCustomer(getSessionData().getCustomer());
80         
81         if (null != errorMsg
82             || null
83                != (errorMsg =
84                getSessionData().getAndClearUserMessage())) {
85         page.setTextErrorText(errorMsg);
86         } else {
87         page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText());
88         }
89
90         HTMLTableRowElement templateRow = page.getElementRowtemplate();
91         Node pickupTable = templateRow.getParentNode();
92         HTMLAnchorElement deliveryURL = page.getElementSelectdelivery();
93         HTMLTableRowElement tempRow = null;
94
95         // Remove ids to prevent duplicates
96
// (browsers don't care, but the DOM does)
97
templateRow.removeAttribute("id");
98         deliveryURL.removeAttribute("id");
99
100        
101         // Build the account history table.
102
for (int i = 0; i < deliveries.length; i++) {
103         Delivery currentDelivery = deliveries[i];
104
105         page.setTextPickupname(currentDelivery.getPickUp().getName());
106         page.setTextPickupaddress(currentDelivery.getPickUp().getStreet1());
107         page.setTextDropoffaddress(currentDelivery.getDropOff().getStreet1());
108         page.setTextDescription(currentDelivery.getDescription());
109         page.setTextOrdernumber(currentDelivery.getHandle());
110         page.setTextPickuptime(currentDelivery.getPickedUpTime());
111         page.setTextDropofftime(currentDelivery.getDroppedOffTime());
112         deliveryURL.setHref("OrderPage1.po?" + AirSentConstants.DELIVERYID
113                     + "=" + currentDelivery.getHandle());
114         
115         tempRow = (HTMLTableRowElement) templateRow.cloneNode(true);
116
117         // Add a deep clone of the row to the DOM
118
pickupTable.appendChild(tempRow);
119         }
120
121         // Finally remove the template row and template select option
122
// from the page
123
templateRow.getParentNode().removeChild(templateRow);
124
125 /*
126  * Catch Null pointer exception ( we canot make a instances of classes from business layer when we run AirSent_pres )
127  * We need to allow AirSent_pres to be functional , response
128  * will be default HTML page
129  *
130  */

131      }catch(NullPointerException JavaDoc e){
132         page.setTextErrorText("This is a default HTML page");
133         HTMLAnchorElement deliveryURL = page.getElementSelectdelivery();
134         deliveryURL.setHref("OrderPage1.po");
135         
136     } catch (Exception JavaDoc e) {
137         throw new AirSentPresentationException("Exception ", e);
138     }
139       return page;
140     }
141
142 }
143
144
Popular Tags