summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/ui-contribution/scatours.html
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/travelsample/ui-contribution/scatours.html')
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.html79
1 files changed, 60 insertions, 19 deletions
diff --git a/sandbox/travelsample/ui-contribution/scatours.html b/sandbox/travelsample/ui-contribution/scatours.html
index 7b1a0b60d8..3ac053f059 100644
--- a/sandbox/travelsample/ui-contribution/scatours.html
+++ b/sandbox/travelsample/ui-contribution/scatours.html
@@ -42,9 +42,9 @@
var travelBooking = new Reference("travelBooking");
//local state
+ var currentTripId;
var searchResponseItems;
- var tripItems;
-
+
//the constructor for trip leg beans
function TripLegType(id,
fromLocation,
@@ -61,7 +61,7 @@
}
function getTripLeg(){
- return new TripLegType("X",
+ return new TripLegType(currentTripId,
document.travelForm.fromLocation.value,
document.travelForm.toLocation.value,
document.travelForm.fromDate.value,
@@ -71,7 +71,7 @@
function init() {
try {
-
+ newTrip();
}
catch(e) {
alert(e);
@@ -127,16 +127,43 @@
var j = 0;
for (var i=0; i<items.length; i++) {
if (items[i].checked == true) {
- travelBooking.addTripItem(items[i].value);
+ travelBooking.addTripItem(currentTripId, items[i].value);
} else {
- travelBooking.removeTripItem(items[i].value);
+ travelBooking.removeTripItem(currentTripId, items[i].value);
}
}
- travelBooking.getTotalPrice(totalPrice_response);
+ travelBooking.getTripItems(currentTripId,getTripItems_response);
+ }
+
+ function getTripItems_response(items, exception) {
+ if(exception){
+ alert(exception.javaStack);
+ return;
+ }
+ var itemsHTML = '<table border="0">';
+ itemsHTML += '<tr>';
+ itemsHTML += '<td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>';
+ itemsHTML += '</tr>';
+
+ for (var i=0; i<items.length; i++) {
+ itemsHTML += '<tr>';
+ itemsHTML += '<td>' + items[i].name + '</td>';
+ itemsHTML += '<td>' + items[i].description + '</td>';
+ itemsHTML += '<td>' + items[i].location + '</td>';
+ itemsHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>';
+ itemsHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>';
+ itemsHTML += '</tr>';
+ }
+
+ itemsHTML += '</table>';
+
+ document.getElementById('tripItems').innerHTML = itemsHTML;
+
+ travelBooking.getTotalPrice(currentTripId, getTotalPrice_response);
}
- function totalPrice_response(totalPrice, exception) {
+ function getTotalPrice_response(totalPrice, exception) {
if(exception){
alert(exception.javaStack);
return;
@@ -145,12 +172,26 @@
}
function newTrip() {
-
+ travelBooking.newTrip(newTrip_response);
+
+ document.getElementById('searchResponse').innerHTML = "";
+ document.getElementById('tripItems').innerHTML = "";
+ document.getElementById('totalPrice').innerHTML = "";
}
+ function newTrip_response(tripId, exception) {
+ if(exception){
+ alert(exception.javaStack);
+ return;
+ }
+ currentTripId = tripId
+ document.getElementById('tripId').innerHTML = "Trip: " + tripId;
+ }
+
function purchaseTrip() {
- travelBooking.purchaseTrip();
+ travelBooking.purchaseTrip(currentTripId);
+ document.getElementById('searchResponse').innerHTML = "";
document.getElementById('tripItems').innerHTML = "Thank you for shopping with SCA Tours";
document.getElementById('totalPrice').innerHTML = "";
searchResponseItems = null;
@@ -164,8 +205,9 @@
<body onload="init()" background="">
<img src="scatours.png" border="0" />
<div id="scatours">
- <br>
- <form name="travelForm">
+ <form name="travelForm">
+ <h3><div id="tripId"></h3>
+ <br/>
<table border="0">
<tr>
<td>From Location:</td>
@@ -196,19 +238,18 @@
<input type="button" onClick="searchFlights()" value="Search Flights">
<input type="button" onClick="searchHotels()" value="Search Cars">
</form>
- <form name="tripForm">
+ <form name="tripForm">
+ <h3>Search Results</h3>
<div id="searchResponse"></div>
<br>
- <input type="button" onClick="newTrip()" value="Create New Trip">
- <br>
- <div id="totalPrice"></div>
- <br>
+ <h3>You Trip</h3>
<div id="tripItems"></div>
+ <br>
+ <div id="totalPrice"></div>
<br>
+ <input type="button" onClick="newTrip()" value="Create New Trip">
<input type="button" onClick="purchaseTrip()" value="Purchase Trip">
</form>
-
-
</div>
</body>