KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > presentation > messenger > Details


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: Details.java,v 1.1 2004/08/16 09:33:18 slobodan Exp $
18  */

19
20 package com.lutris.airsent.presentation.messenger;
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 org.enhydra.xml.xmlc.XMLCUtil;
27 import org.enhydra.xml.xmlc.XMLObject;
28 import org.w3c.dom.*;
29 import java.util.Date JavaDoc;
30 import com.lutris.airsent.presentation.AirSentPresentationException;
31 import com.lutris.airsent.presentation.AirSentConstants;
32 import com.lutris.airsent.presentation.DeviceBasePO;
33 import com.lutris.airsent.spec.delivery.Delivery;
34 import com.lutris.airsent.presentation.DeviceUtils;
35 import java.lang.reflect.Method JavaDoc;
36
37 /**
38  * Details.java handles the delivery details of the messenger portion
39  * of the app.
40  */

41 public class Details extends DeviceBasePO {
42
43     /**
44      * Constants
45      */

46     private static final int AUTH_LEVEL = AirSentConstants.UNAUTH_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      * @return wml document
62      * @exception HttpPresentationException
63      */

64     public XMLObject handleDefault() throws HttpPresentationException {
65     return showPage(null);
66     }
67
68     /**
69      * Displays the Delivery Details page
70      *
71      * @param errorMsg, the error messages
72      * @return wml document
73      * @exception HttpPresentationException
74      */

75     public XMLObject showPage(String JavaDoc errorMsg)
76         throws HttpPresentationException {
77   
78   Class JavaDoc tempClass=null;
79         Object JavaDoc page= null;
80         Method JavaDoc setTextErrorText = null;
81         Method JavaDoc setTextName = null;
82         Method JavaDoc setTextAddress = null;
83         Method JavaDoc setTextDirections = null;
84         Method JavaDoc getTagComplete = null;
85       
86         try{
87         Class JavaDoc stringClass=Class.forName("java.lang.String");
88         tempClass = Class.forName(DeviceUtils.getPageName(myComms, "com.lutris.airsent.presentation.messenger.Details"));
89         page= myComms.xmlcFactory.create(tempClass);
90         Class JavaDoc[] argTypeArr={stringClass};
91         setTextErrorText= tempClass.getMethod("setTextErrorText",argTypeArr);
92         setTextName= tempClass.getMethod("setTextName",argTypeArr);
93         setTextAddress= tempClass.getMethod("setTextAddress",argTypeArr);
94         setTextDirections= tempClass.getMethod("setTextDirections",argTypeArr);
95         getTagComplete = tempClass.getMethod("getElementComplete",null);
96       }catch(Exception JavaDoc e){}
97   
98     //DetailsPage page =
99
//(DetailsPage) create("com.lutris.airsent.presentation.messenger.Details");
100
try{
101     if (null != errorMsg
102         || null
103            != (errorMsg =
104                this.getSessionData().getAndClearUserMessage())) {
105         Object JavaDoc [] temp={errorMsg};
106         setTextErrorText.invoke(page,temp);
107         //page.setTextErrorText(errorMsg);
108

109         return ((XMLObject)page);
110     } else {
111         Object JavaDoc [] temp={""};
112         setTextErrorText.invoke(page,temp);
113         //page.setTextErrorText("");
114
}
115 }catch(Exception JavaDoc e){}
116     String JavaDoc pageSelection =
117         myComms.request.getParameter(AirSentConstants.SELECTION_NAME);
118     String JavaDoc deliveryID =
119         myComms.request.getParameter(AirSentConstants.DELIVERYID);
120     String JavaDoc name = null;
121     String JavaDoc address = null;
122     String JavaDoc directions = null;
123     Delivery delivery = null;
124
125     try {
126         if ((delivery =
127          getApplication().getHomeManager().getDeliveryManager().findByHandle(deliveryID))
128             == null) {
129         return showPage("Could not find delivery");
130         }
131
132         if (pageSelection == null) {
133         return showPage("Error in pickup or delivery");
134         }
135
136         if (pageSelection.equals(AirSentConstants.PICKUP)) {
137         name = delivery.getPickUp().getName();
138         address = delivery.getPickUp().getStreet1();
139         directions = delivery.getPickUp().getDirections();
140         } else {
141         name = delivery.getDropOff().getName();
142         address = delivery.getDropOff().getStreet1();
143         directions = delivery.getDropOff().getDirections();
144         }
145         Object JavaDoc [] temp1={name};
146         setTextName.invoke(page,temp1);
147         //page.setTextName(name);
148
Object JavaDoc [] temp2={address};
149         setTextAddress.invoke(page,temp2);
150         //page.setTextAddress(address);
151
Object JavaDoc [] temp3={directions};
152         setTextDirections.invoke(page,temp3);
153         //page.setTextDirections(directions);
154
//page.getTagComplete().getAttributeNode("href").setValue(AirSentConstants.DISPLAY_PO
155
((Element)getTagComplete.invoke(page,null)).getAttributeNode("href").setValue(AirSentConstants.DISPLAY_PO
156                           + "?event=complete" + "&"
157                           + "deliveryID="
158                           + delivery.getHandle()
159                           + "&"
160                           + AirSentConstants.SELECTION_NAME
161                           + "=" + pageSelection);
162         
163     } catch (Exception JavaDoc e) {
164         throw new AirSentPresentationException("System error showing page", e);
165     }
166     DeviceUtils.setURLTimeStamp((XMLObject)page);
167     return ((XMLObject)page);
168     }
169
170 }
171
172
173
174
Popular Tags