001: /*
002: * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
003: * Reserved.
004: *
005: * This source code file is distributed by Lutris Technologies, Inc. for
006: * use only by licensed users of product(s) that include this source
007: * file. Use of this source file or the software that uses it is covered
008: * by the terms and conditions of the Lutris Enhydra Development License
009: * Agreement included with this product.
010: *
011: * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
012: * ANY KIND, either express or implied. See the License for the specific terms
013: * governing rights and limitations under the License.
014: *
015: * Contributor(s):
016: *
017: * $Id: Details.java,v 1.1 2006-09-11 12:29:26 sinisa Exp $
018: */
019:
020: package com.lutris.airsent.presentation.messenger;
021:
022: import com.lutris.appserver.server.httpPresentation.*;
023: import com.lutris.appserver.server.session.*;
024: import com.lutris.util.*; //import com.lutris.xml.xmlc.*;
025: import org.enhydra.xml.xmlc.XMLCUtil;
026: import org.enhydra.xml.xmlc.XMLObject;
027: import org.w3c.dom.*;
028: import java.util.Date;
029: import com.lutris.airsent.presentation.AirSentPresentationException;
030: import com.lutris.airsent.presentation.AirSentConstants;
031: import com.lutris.airsent.presentation.DeviceBasePO;
032: import com.lutris.airsent.spec.delivery.Delivery;
033: import com.lutris.airsent.presentation.DeviceUtils;
034: import java.lang.reflect.Method;
035:
036: /**
037: * Details.java handles the delivery details of the messenger portion
038: * of the app.
039: */
040: public class Details extends DeviceBasePO {
041:
042: /**
043: * Constants
044: */
045: private static final int AUTH_LEVEL = AirSentConstants.UNAUTH_USER;
046:
047: /**
048: * Superclass method override.
049: * returns the authorization level necessary to access this po.
050: *
051: * @return int required authorization level
052: */
053: public int getRequiredAuthLevel() {
054: return AUTH_LEVEL;
055: }
056:
057: /**
058: * Default event. Just show the page.
059: *
060: * @return wml document
061: * @exception HttpPresentationException
062: */
063: public XMLObject handleDefault() throws HttpPresentationException {
064: return showPage(null);
065: }
066:
067: /**
068: * Displays the Delivery Details page
069: *
070: * @param errorMsg, the error messages
071: * @return wml document
072: * @exception HttpPresentationException
073: */
074: public XMLObject showPage(String errorMsg)
075: throws HttpPresentationException {
076:
077: Class tempClass = null;
078: Object page = null;
079: Method setTextErrorText = null;
080: Method setTextName = null;
081: Method setTextAddress = null;
082: Method setTextDirections = null;
083: Method getTagComplete = null;
084:
085: try {
086: Class stringClass = Class.forName("java.lang.String");
087: tempClass = Class
088: .forName(DeviceUtils
089: .getPageName(myComms,
090: "com.lutris.airsent.presentation.messenger.Details"));
091: page = myComms.xmlcFactory.create(tempClass);
092: Class[] argTypeArr = { stringClass };
093: setTextErrorText = tempClass.getMethod("setTextErrorText",
094: argTypeArr);
095: setTextName = tempClass
096: .getMethod("setTextName", argTypeArr);
097: setTextAddress = tempClass.getMethod("setTextAddress",
098: argTypeArr);
099: setTextDirections = tempClass.getMethod(
100: "setTextDirections", argTypeArr);
101: getTagComplete = tempClass.getMethod("getElementComplete",
102: null);
103: } catch (Exception e) {
104: }
105:
106: //DetailsPage page =
107: //(DetailsPage) create("com.lutris.airsent.presentation.messenger.Details");
108: try {
109: if (null != errorMsg
110: || null != (errorMsg = this .getSessionData()
111: .getAndClearUserMessage())) {
112: Object[] temp = { errorMsg };
113: setTextErrorText.invoke(page, temp);
114: //page.setTextErrorText(errorMsg);
115:
116: return ((XMLObject) page);
117: } else {
118: Object[] temp = { "" };
119: setTextErrorText.invoke(page, temp);
120: //page.setTextErrorText("");
121: }
122: } catch (Exception e) {
123: }
124: String pageSelection = myComms.request
125: .getParameter(AirSentConstants.SELECTION_NAME);
126: String deliveryID = myComms.request
127: .getParameter(AirSentConstants.DELIVERYID);
128: String name = null;
129: String address = null;
130: String directions = null;
131: Delivery delivery = null;
132:
133: try {
134: if ((delivery = getApplication().getHomeManager()
135: .getDeliveryManager().findByHandle(deliveryID)) == null) {
136: return showPage("Could not find delivery");
137: }
138:
139: if (pageSelection == null) {
140: return showPage("Error in pickup or delivery");
141: }
142:
143: if (pageSelection.equals(AirSentConstants.PICKUP)) {
144: name = delivery.getPickUp().getName();
145: address = delivery.getPickUp().getStreet1();
146: directions = delivery.getPickUp().getDirections();
147: } else {
148: name = delivery.getDropOff().getName();
149: address = delivery.getDropOff().getStreet1();
150: directions = delivery.getDropOff().getDirections();
151: }
152: Object[] temp1 = { name };
153: setTextName.invoke(page, temp1);
154: //page.setTextName(name);
155: Object[] temp2 = { address };
156: setTextAddress.invoke(page, temp2);
157: //page.setTextAddress(address);
158: Object[] temp3 = { directions };
159: setTextDirections.invoke(page, temp3);
160: //page.setTextDirections(directions);
161: //page.getTagComplete().getAttributeNode("href").setValue(AirSentConstants.DISPLAY_PO
162: ((Element) getTagComplete.invoke(page, null))
163: .getAttributeNode("href").setValue(
164: AirSentConstants.DISPLAY_PO
165: + "?event=complete" + "&"
166: + "deliveryID="
167: + delivery.getHandle() + "&"
168: + AirSentConstants.SELECTION_NAME
169: + "=" + pageSelection);
170:
171: } catch (Exception e) {
172: throw new AirSentPresentationException(
173: "System error showing page", e);
174: }
175: DeviceUtils.setURLTimeStamp((XMLObject) page);
176: return ((XMLObject) page);
177: }
178:
179: }
|