diff options
Diffstat (limited to 'java/sca/samples/store-webapp/src/main/webapp')
4 files changed, 271 insertions, 0 deletions
diff --git a/java/sca/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml b/java/sca/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..41c84c9a44 --- /dev/null +++ b/java/sca/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:store="http://store"> + <deployable composite="store:store"/> +</contribution>
\ No newline at end of file diff --git a/java/sca/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/java/sca/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..d191961f95 --- /dev/null +++ b/java/sca/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<web:web-app + xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" + xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" + xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" + xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" + xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-2.0" + xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" + xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" + xmlns:pers="http://java.sun.com/xml/ns/persistence" + xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" + xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" + xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"> + <dep:environment> + <dep:moduleId> + <dep:groupId>org.apache.tuscany</dep:groupId> + <dep:artifactId>sample-store-secure-webapp</dep:artifactId> + <dep:version>1.0</dep:version> + <dep:type>car</dep:type> + </dep:moduleId> + + <!-- TUSCANY-2622 --> + <dep:hidden-classes> + <dep:filter>org.apache.axiom</dep:filter> + <dep:filter>org.apache.axis2</dep:filter> + <dep:filter>org.apache.commons</dep:filter> + <dep:filter>org.jdom</dep:filter> + </dep:hidden-classes> + + </dep:environment> + <web:context-root>/sample-store-secure-webapp</web:context-root> +</web:web-app> diff --git a/java/sca/samples/store-webapp/src/main/webapp/WEB-INF/web.xml b/java/sca/samples/store-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..348be0df21 --- /dev/null +++ b/java/sca/samples/store-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> + <display-name>sample-store-secure-webapp</display-name> + + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list id="WelcomeFileList"> + <welcome-file>store.html</welcome-file> + </welcome-file-list> +</web-app>
\ No newline at end of file diff --git a/java/sca/samples/store-webapp/src/main/webapp/store.html b/java/sca/samples/store-webapp/src/main/webapp/store.html new file mode 100644 index 0000000000..ba004e02ac --- /dev/null +++ b/java/sca/samples/store-webapp/src/main/webapp/store.html @@ -0,0 +1,162 @@ +<!-- + * 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 tuscany.sca.Reference("catalog"); + + //@Reference + var shoppingCart = new tuscany.sca.Reference("shoppingCart"); + + //@Reference + var shoppingTotal = new tuscany.sca.Reference("shoppingTotal"); + + var catalogItems; + + function catalog_getResponse(items,exception) { + if(exception){ + alert(exception.message); + return; + } + var catalog = ""; + + for (var i=0; i<items.length; i++) { + var item = items[i].name + ' - ' + items[i].price; + catalog += '<input name="items" type="checkbox" value="' + + item + '">' + item + ' <br>'; + } + document.getElementById('catalog').innerHTML=catalog; + catalogItems = items; + } + + function shoppingCart_getResponse(feed) { + if (feed != null) { + var entries = feed.getElementsByTagName("entry"); + var list = ""; + for (var i=0; i<entries.length; i++) { + var content = entries[i].getElementsByTagName("content")[0]; + var name = content.getElementsByTagName("name")[0].firstChild.nodeValue; + var price = content.getElementsByTagName("price")[0].firstChild.nodeValue; + list += name + ' - ' + price + ' <br>'; + } + document.getElementById("shoppingCart").innerHTML = list; + + if (entries.length != 0) { + try { + shoppingTotal.getTotal(shoppingTotal_getTotalResponse); + } + catch(e){ + alert(e); + } + } + } + } + + function shoppingTotal_getTotalResponse(total,exception) { + if(exception) { + alert(exception.message); + return; + } + document.getElementById('total').innerHTML = total; + } + + 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>item</title><content type="text/xml">' + + '<Item xmlns="http://services/">' + + '<name xmlns="">' + catalogItems[i].name + '</name>' + '<price xmlns="">' + catalogItems[i].price + '</price>' + + '</Item>' + '</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">'+ + 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 = ""; + } + + function init() { + + try { + catalog.get(catalog_getResponse); + shoppingCart.get("", shoppingCart_getResponse); + } + catch(e){ + alert(e); + } + } + +</script> + +</head> + +<body onload="init()"> +<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/Cart/">(feed)</a> + </form> + </div> +</body> +</html> |