You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/10/29 05:46:07 UTC
svn commit: r589494 - in /incubator/tuscany/java/sca/tutorial:
assets/services/merged/ assets/services/merger/ assets/uiservices/
cloud/launch/ cloud/launch/cloud/ store-eu/ store-eu/launch/
store-eu/launch/eu/ store-eu/uiservices/ store/ store/launch/...
Author: jsdelfino
Date: Sun Oct 28 21:46:04 2007
New Revision: 589494
URL: http://svn.apache.org/viewvc?rev=589494&view=rev
Log:
Refactored the launch programs, renamed merged to merger, changed composites and HTML pages to use implementation.widget instead of implementation.resource.
Added:
incubator/tuscany/java/sca/tutorial/assets/services/merger/
- copied from r589209, incubator/tuscany/java/sca/tutorial/assets/services/merged/
incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java
- copied, changed from r589209, incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java
incubator/tuscany/java/sca/tutorial/store-eu/launch/LaunchEUStore.java
- copied, changed from r589209, incubator/tuscany/java/sca/tutorial/store-eu/launch/eu/LaunchEUStore.java
incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java
- copied, changed from r589209, incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java
incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java (with props)
incubator/tuscany/java/sca/tutorial/store/uiservices/store.html
Removed:
incubator/tuscany/java/sca/tutorial/assets/services/merged/
incubator/tuscany/java/sca/tutorial/assets/uiservices/binding-atom.js
incubator/tuscany/java/sca/tutorial/assets/uiservices/binding-jsonrpc.js
incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/
incubator/tuscany/java/sca/tutorial/store-eu/launch/eu/
incubator/tuscany/java/sca/tutorial/store-eu/uiservices/binding-atom.js
incubator/tuscany/java/sca/tutorial/store-eu/uiservices/binding-jsonrpc.js
incubator/tuscany/java/sca/tutorial/store/launch/merged/
incubator/tuscany/java/sca/tutorial/store/launch/store/
incubator/tuscany/java/sca/tutorial/store/uiservices/binding-atom.js
incubator/tuscany/java/sca/tutorial/store/uiservices/binding-jsonrpc.js
Modified:
incubator/tuscany/java/sca/tutorial/assets/services/merger/MergedCatalogImpl.java
incubator/tuscany/java/sca/tutorial/assets/uiservices/store.html
incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite
incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html
incubator/tuscany/java/sca/tutorial/store/pom.xml
incubator/tuscany/java/sca/tutorial/store/store-merged.composite
incubator/tuscany/java/sca/tutorial/store/store.composite
Modified: incubator/tuscany/java/sca/tutorial/assets/services/merger/MergedCatalogImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/assets/services/merger/MergedCatalogImpl.java?rev=589494&r1=589209&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/assets/services/merger/MergedCatalogImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/assets/services/merger/MergedCatalogImpl.java Sun Oct 28 21:46:04 2007
@@ -17,7 +17,7 @@
* under the License.
*/
-package services.merged;
+package services.merger;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
Modified: incubator/tuscany/java/sca/tutorial/assets/uiservices/store.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/assets/uiservices/store.html?rev=589494&r1=589493&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/assets/uiservices/store.html (original)
+++ incubator/tuscany/java/sca/tutorial/assets/uiservices/store.html Sun Oct 28 21:46:04 2007
@@ -16,108 +16,105 @@
* specific language governing permissions and limitations
* under the License.
-->
-<html>
-<head>
-<title>Store</TITLE>
-
-<script type="text/javascript" src="binding-atom.js"></script>
-<script type="text/javascript" src="binding-jsonrpc.js"></script>
-<script language="JavaScript">
-
- //Reference
- catalog = (new JSONRpcClient("../Catalog")).Catalog;
- //Reference
- shoppingCart = new AtomClient("../ShoppingCart");
-
-
- function catalog_getResponse(items) {
+<html>
+<head>
+<title>Store</TITLE>
+
+<script type="text/javascript" src="store.js"></script>
+
+<script language="JavaScript">
+
+ //@Reference
+ var catalog = new Reference("catalog");
+
+ //@Reference
+ var shoppingCart = new Reference("shoppingCart");
+
+
+ function catalog_getResponse(items) {
var catalog = "";
- //fixme
- items = items.String_collection.String;
for (var i=0; i<items.length; i++) {
- //fixme
- var item = items[i]["$"];
catalog += '<input name="items" type="checkbox" value="' +
- item + '">' + item + ' <br>';
+ items[i] + '">' + items[i] + ' <br>';
}
document.getElementById('catalog').innerHTML=catalog;
- }
-
- function shoppingCart_getResponse(feed) {
- if (feed != null) {
- var entries = feed.getElementsByTagName("entry");
- var list = "";
- for (var i=0; i<entries.length; i++) {
- var item = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
+ }
+
+ function shoppingCart_getResponse(feed) {
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ var list = "";
+ for (var i=0; i<entries.length; i++) {
+ var item = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
list += item + ' <br>';
- }
+ }
document.getElementById("shoppingCart").innerHTML = list;
- document.getElementById('total').innerHTML = feed.getElementsByTagName("subtitle")[0].firstChild.nodeValue;
- }
- }
- function shoppingCart_postResponse(entry) {
- shoppingCart.get("", shoppingCart_getResponse);
- }
-
-
- function addToCart() {
- var items = document.catalogForm.items;
- var j = 0;
- for (var i=0; i<items.length; i++)
- if (items[i].checked) {
- var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>cart-item</title><content type="text">'+items[i].value+'</content></entry>'
- shoppingCart.post(entry, shoppingCart_postResponse);
- items[i].checked = false;
- }
- }
- function checkoutCart() {
- document.getElementById('store').innerHTML='<h2>' +
- 'Thanks for Shopping With Us!</h2>'+
- '<h2>Your Order</h2>'+
- '<form name="orderForm" action="/ui/store.html">'+
- document.getElementById('shoppingCart').innerHTML+
- '<br>'+
- document.getElementById('total').innerHTML+
- '<br>'+
- '<br>'+
- '<input type="submit" value="Continue Shopping">'+
- '</form>';
- shoppingCart.del("", null);
- }
- function deleteCart() {
- shoppingCart.del("", null);
- document.getElementById('shoppingCart').innerHTML = "";
- document.getElementById('total').innerHTML = "";
- }
-
- catalog.get(catalog_getResponse);
+ document.getElementById('total').innerHTML = feed.getElementsByTagName("subtitle")[0].firstChild.nodeValue;
+ }
+ }
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.get("", shoppingCart_getResponse);
+ }
+
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++)
+ if (items[i].checked) {
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>cart-item</title><content type="text">'+items[i].value+'</content></entry>'
+ shoppingCart.post(entry, shoppingCart_postResponse);
+ items[i].checked = false;
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='<h2>' +
+ 'Thanks for Shopping With Us!</h2>'+
+ '<h2>Your Order</h2>'+
+ '<form name="orderForm" action="/ui/store.html">'+
+ document.getElementById('shoppingCart').innerHTML+
+ '<br>'+
+ document.getElementById('total').innerHTML+
+ '<br>'+
+ '<br>'+
+ '<input type="submit" value="Continue Shopping">'+
+ '</form>';
+ shoppingCart.del("", null);
+ }
+ function deleteCart() {
+ shoppingCart.del("", null);
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+ catalog.get(catalog_getResponse);
shoppingCart.get("", shoppingCart_getResponse);
-</script>
-
-</head>
-
-<body>
-<h1>Store</h1>
- <div id="store">
- <h2>Catalog</h2>
- <form name="catalogForm">
- <div id="catalog" ></div>
- <br>
- <input type="button" onClick="addToCart()" value="Add to Cart">
- </form>
-
- <br>
-
+</script>
+
+</head>
+
+<body>
+<h1>Store</h1>
+ <div id="store">
+ <h2>Catalog</h2>
+ <form name="catalogForm">
+ <div id="catalog" ></div>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
+ </form>
+
+ <br>
+
<h2>Your Shopping Cart</h2>
- <form name="shoppingCartForm">
+ <form name="shoppingCartForm">
<div id="shoppingCart"></div>
<br>
- <div id="total"></div>
- <br>
- <input type="button" onClick="checkoutCart()" value="Checkout">
- <input type="button" onClick="deleteCart()" value="Empty">
+ <div id="total"></div>
+ <br>
+ <input type="button" onClick="checkoutCart()" value="Checkout">
+ <input type="button" onClick="deleteCart()" value="Empty">
<a href="../ShoppingCart/">(feed)</a>
- </form>
- </div>
-</body>
-</html>
+ </form>
+ </div>
+</body>
+</html>
Copied: incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java (from r589209, incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java?p2=incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java&p1=incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java&r1=589209&r2=589494&rev=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java (original)
+++ incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java Sun Oct 28 21:46:04 2007
@@ -17,7 +17,7 @@
* under the License.
*/
-package launch.cloud;
+package launch;
import java.net.URL;
Copied: incubator/tuscany/java/sca/tutorial/store-eu/launch/LaunchEUStore.java (from r589209, incubator/tuscany/java/sca/tutorial/store-eu/launch/eu/LaunchEUStore.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-eu/launch/LaunchEUStore.java?p2=incubator/tuscany/java/sca/tutorial/store-eu/launch/LaunchEUStore.java&p1=incubator/tuscany/java/sca/tutorial/store-eu/launch/eu/LaunchEUStore.java&r1=589209&r2=589494&rev=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-eu/launch/eu/LaunchEUStore.java (original)
+++ incubator/tuscany/java/sca/tutorial/store-eu/launch/LaunchEUStore.java Sun Oct 28 21:46:04 2007
@@ -17,7 +17,7 @@
* under the License.
*/
-package launch.eu;
+package launch;
import java.net.URL;
Modified: incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite?rev=589494&r1=589493&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite Sun Oct 28 21:46:04 2007
@@ -22,13 +22,19 @@
targetNamespace="http://store"
name="store-eu">
- <component name="ui">
- <t:implementation.resource location="uiservices"/>
- <service name="Resource">
- <t:binding.http/>
- </service>
- </component>
-
+ <component name="store">
+ <t:implementation.widget location="uiservices/store.html"/>
+ <service name="Widget">
+ <t:binding.http/>
+ </service>
+ <reference name="catalog" target="Catalog">
+ <t:binding.jsonrpc/>
+ </reference>
+ <reference name="shoppingCart" target="ShoppingCart">
+ <t:binding.atom/>
+ </reference>
+ </component>
+
<component name="ShoppingCart">
<implementation.java class="services.ShoppingCartImpl"/>
<service name="Collection">
@@ -37,11 +43,11 @@
</component>
<component name="Catalog">
- <implementation.java class="services.merged.MergedCatalogImpl"/>
+ <implementation.java class="services.merger.MergedCatalogImpl"/>
<property name="currencyCode">EUR</property>
<service name="Catalog">
- <t:binding.jsonrpc uri="CatalogJS"/>
- <binding.ws uri="CatalogWS"/>
+ <t:binding.jsonrpc/>
+ <binding.ws uri="CatalogWebService"/>
</service>
<reference name="fruitsCatalog" target="CloudFruitsCatalog"/>
<reference name="vegetablesCatalog" target="CloudVegetablesCatalog"/>
Modified: incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html?rev=589494&r1=589493&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html (original)
+++ incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html Sun Oct 28 21:46:04 2007
@@ -20,14 +20,15 @@
<head>
<title>Store</TITLE>
-<script type="text/javascript" src="binding-atom.js"></script>
-<script type="text/javascript" src="binding-jsonrpc.js"></script>
+<script type="text/javascript" src="store.js"></script>
+
<script language="JavaScript">
- //Reference
- catalog = (new JSONRpcClient("../CatalogJS")).Catalog;
- //Reference
- shoppingCart = new AtomClient("../ShoppingCart");
+ //@Reference
+ var catalog = new Reference("catalog");
+
+ //@Reference
+ var shoppingCart = new Reference("shoppingCart");
function catalog_getResponse(items) {
Copied: incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java (from r589209, incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java?p2=incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java&p1=incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java&r1=589209&r2=589494&rev=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java (original)
+++ incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java Sun Oct 28 21:46:04 2007
@@ -17,7 +17,7 @@
* under the License.
*/
-package launch.store;
+package launch;
import java.net.URL;
@@ -31,7 +31,7 @@
public static void main(String[] args) throws Exception {
System.out.println("Starting ...");
SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- SCANode node = nodeFactory.createSCANode("http://localhost:8100/store", "http://localhost:9999");
+ SCANode node = nodeFactory.createSCANode(null, "http://localhost:9999");
URL contribution = SCAContributionUtil.findContributionFromClass(LaunchStore.class);
node.addContribution("http://store", contribution);
Added: incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java?rev=589494&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java (added)
+++ incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java Sun Oct 28 21:46:04 2007
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launch;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.util.SCAContributionUtil;
+
+public class LaunchStoreMerger {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ...");
+ SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+ SCANode node = nodeFactory.createSCANode("http://localhost:8101/store", "http://localhost:9999");
+
+ URL contribution = SCAContributionUtil.findContributionFromClass(LaunchStoreMerger.class);
+ node.addContribution("http://store", contribution);
+
+ node.addToDomainLevelComposite(new QName("http://store", "store-merger"));
+ node.start();
+
+ System.out.println("store-merger.composite ready for big business !!!");
+ System.in.read();
+
+ System.out.println("Stopping ...");
+ node.stop();
+ node.destroy();
+ System.out.println();
+ }
+}
Propchange: incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/tutorial/store/launch/LaunchStoreMerger.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/tutorial/store/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/pom.xml?rev=589494&r1=589493&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/pom.xml (original)
+++ incubator/tuscany/java/sca/tutorial/store/pom.xml Sun Oct 28 21:46:04 2007
@@ -64,7 +64,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-resource</artifactId>
+ <artifactId>tuscany-implementation-widget</artifactId>
<version>1.1-incubating-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Modified: incubator/tuscany/java/sca/tutorial/store/store-merged.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/store-merged.composite?rev=589494&r1=589493&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/store-merged.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store/store-merged.composite Sun Oct 28 21:46:04 2007
@@ -20,15 +20,21 @@
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
targetNamespace="http://store"
- name="store-merged">
+ name="store-merger">
- <component name="ui">
- <t:implementation.resource location="uiservices"/>
- <service name="Resource">
- <t:binding.http/>
- </service>
- </component>
-
+ <component name="store">
+ <t:implementation.widget location="uiservices/store.html"/>
+ <service name="Widget">
+ <t:binding.http/>
+ </service>
+ <reference name="catalog" target="Catalog">
+ <t:binding.jsonrpc/>
+ </reference>
+ <reference name="shoppingCart" target="ShoppingCart">
+ <t:binding.atom/>
+ </reference>
+ </component>
+
<component name="FruitsCatalog">
<implementation.java class="services.FruitsCatalogImpl"/>
<property name="currencyCode">USD</property>
@@ -36,11 +42,11 @@
</component>
<component name="Catalog">
- <implementation.java class="services.merged.MergedCatalogImpl"/>
+ <implementation.java class="services.merger.MergedCatalogImpl"/>
<property name="currencyCode">USD</property>
<service name="Catalog">
- <t:binding.jsonrpc uri="CatalogJS"/>
- <binding.ws uri="CatalogWS"/>
+ <t:binding.jsonrpc/>
+ <binding.ws uri="CatalogWebService"/>
</service>
<reference name="fruitsCatalog" target="FruitsCatalog"/>
<reference name="vegetablesCatalog" target="CloudVegetablesCatalog"/>
Modified: incubator/tuscany/java/sca/tutorial/store/store.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/store.composite?rev=589494&r1=589493&r2=589494&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/store.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store/store.composite Sun Oct 28 21:46:04 2007
@@ -22,18 +22,24 @@
targetNamespace="http://store"
name="store">
- <component name="ui">
- <t:implementation.resource location="uiservices"/>
- <service name="Resource">
- <t:binding.http/>
- </service>
- </component>
-
+ <component name="store">
+ <t:implementation.widget location="uiservices/store.html"/>
+ <service name="Widget">
+ <t:binding.http/>
+ </service>
+ <reference name="catalog" target="Catalog">
+ <t:binding.jsonrpc/>
+ </reference>
+ <reference name="shoppingCart" target="ShoppingCart">
+ <t:binding.atom/>
+ </reference>
+ </component>
+
<component name="Catalog">
<implementation.java class="services.FruitsCatalogImpl"/>
<property name="currencyCode">USD</property>
<service name="Catalog">
- <t:binding.jsonrpc uri="CatalogJS"/>
+ <t:binding.jsonrpc/>
</service>
<reference name="currencyConverter" target="CurrencyConverter"/>
</component>
Added: incubator/tuscany/java/sca/tutorial/store/uiservices/store.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/uiservices/store.html?rev=589494&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/uiservices/store.html (added)
+++ incubator/tuscany/java/sca/tutorial/store/uiservices/store.html Sun Oct 28 21:46:04 2007
@@ -0,0 +1,120 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<title>Store</TITLE>
+
+<script type="text/javascript" src="store.js"></script>
+
+<script language="JavaScript">
+
+ //@Reference
+ var catalog = new Reference("catalog");
+
+ //@Reference
+ var shoppingCart = new Reference("shoppingCart");
+
+
+ function catalog_getResponse(items) {
+ var catalog = "";
+ for (var i=0; i<items.length; i++) {
+ catalog += '<input name="items" type="checkbox" value="' +
+ items[i] + '">' + items[i] + ' <br>';
+ }
+ document.getElementById('catalog').innerHTML=catalog;
+ }
+
+ function shoppingCart_getResponse(feed) {
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ var list = "";
+ for (var i=0; i<entries.length; i++) {
+ var item = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
+ list += item + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+ document.getElementById('total').innerHTML = feed.getElementsByTagName("subtitle")[0].firstChild.nodeValue;
+ }
+ }
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.get("", shoppingCart_getResponse);
+ }
+
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++)
+ if (items[i].checked) {
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>cart-item</title><content type="text">'+items[i].value+'</content></entry>'
+ shoppingCart.post(entry, shoppingCart_postResponse);
+ items[i].checked = false;
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='<h2>' +
+ 'Thanks for Shopping With Us!</h2>'+
+ '<h2>Your Order</h2>'+
+ '<form name="orderForm" action="/ui/store.html">'+
+ document.getElementById('shoppingCart').innerHTML+
+ '<br>'+
+ document.getElementById('total').innerHTML+
+ '<br>'+
+ '<br>'+
+ '<input type="submit" value="Continue Shopping">'+
+ '</form>';
+ shoppingCart.del("", null);
+ }
+ function deleteCart() {
+ shoppingCart.del("", null);
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+ catalog.get(catalog_getResponse);
+ shoppingCart.get("", shoppingCart_getResponse);
+</script>
+
+</head>
+
+<body>
+<h1>Store</h1>
+ <div id="store">
+ <h2>Catalog</h2>
+ <form name="catalogForm">
+ <div id="catalog" ></div>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
+ </form>
+
+ <br>
+
+ <h2>Your Shopping Cart</h2>
+ <form name="shoppingCartForm">
+ <div id="shoppingCart"></div>
+ <br>
+ <div id="total"></div>
+ <br>
+ <input type="button" onClick="checkoutCart()" value="Checkout">
+ <input type="button" onClick="deleteCart()" value="Empty">
+ <a href="../ShoppingCart/">(feed)</a>
+ </form>
+ </div>
+</body>
+</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org