diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-27 06:57:31 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-27 06:57:31 +0000 |
commit | 0fa885699a8225377dbdcbcf0fc5be9625a81ede (patch) | |
tree | 0502084ee2577cc2b6fc3831a048bb74a4449b3f /sca-cpp/trunk/samples/store-gae | |
parent | 0f106d216277e82a83514e689d404a283be06d9b (diff) |
Simplify Javascript component reference API a bit. Rename tuscany-ref.js to ref.js. Add a function to declare reference proxy methods.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027835 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/samples/store-gae')
-rw-r--r-- | sca-cpp/trunk/samples/store-gae/htdocs/index.html | 28 | ||||
-rw-r--r-- | sca-cpp/trunk/samples/store-gae/shopping-cart.py | 8 |
2 files changed, 15 insertions, 21 deletions
diff --git a/sca-cpp/trunk/samples/store-gae/htdocs/index.html b/sca-cpp/trunk/samples/store-gae/htdocs/index.html index 8907cc6b49..3823f58f14 100644 --- a/sca-cpp/trunk/samples/store-gae/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-gae/htdocs/index.html @@ -20,19 +20,13 @@ <head>
<title>Store</title>
-<script type="text/javascript" src="/js/tuscany-ref.js"></script>
+<script type="text/javascript" src="/js/ref.js"></script>
<script type="text/javascript">
-var component = new tuscany.sca.Component("Store");
-
-//@Reference
-var catalog = new tuscany.sca.Reference("catalog");
-
-//@Reference
-var shoppingCart = new tuscany.sca.Reference("shoppingCart");
-
-//@Reference
-var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
+var store = component("Store");
+var catalog = defun(reference(store, "catalog"), "items");
+var shoppingCart = defun(reference(store, "shoppingCart"), "email", "host");
+var shoppingTotal = defun(reference(store, "shoppingTotal"), "total");
var catalogItems;
@@ -51,7 +45,7 @@ function catalog_itemsResponse(items, exception) { catalogItems = items;
}
-function shoppingCart_gethostResponse(host, exception) {
+function shoppingCart_hostResponse(host, exception) {
if (exception) {
alert(exception.message);
return;
@@ -59,7 +53,7 @@ function shoppingCart_gethostResponse(host, exception) { document.getElementById('host').innerHTML = host;
}
-function shoppingCart_getemailResponse(email, exception) {
+function shoppingCart_emailResponse(email, exception) {
if (exception) {
alert(exception.message);
return;
@@ -79,7 +73,7 @@ function shoppingCart_getResponse(feed) { }
document.getElementById("shoppingCart").innerHTML = list;
- shoppingTotal.apply("total", shoppingTotal_totalResponse);
+ shoppingTotal.total(shoppingTotal_totalResponse);
}
}
@@ -136,9 +130,9 @@ function deleteCart() { function init() {
try {
- catalog.apply("items", catalog_itemsResponse);
- shoppingCart.apply("getemail", shoppingCart_getemailResponse);
- shoppingCart.apply("gethost", shoppingCart_gethostResponse);
+ catalog.items(catalog_itemsResponse);
+ shoppingCart.email(shoppingCart_emailResponse);
+ shoppingCart.host(shoppingCart_hostResponse);
shoppingCart.get("", shoppingCart_getResponse);
} catch(e){
alert(e);
diff --git a/sca-cpp/trunk/samples/store-gae/shopping-cart.py b/sca-cpp/trunk/samples/store-gae/shopping-cart.py index 6501f3db8d..3c3168d77b 100644 --- a/sca-cpp/trunk/samples/store-gae/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-gae/shopping-cart.py @@ -73,10 +73,10 @@ def total(cache, host, email): return sum(cart) # Return the email of the cart owner -def getemail(cache, host, email): - return email.eval() +def email(cache, host, email_): + return email_.eval() # Return the host that the app is running on -def gethost(cache, host, email): - return host.eval() +def host(cache, host_, email): + return host_.eval() |