Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/CatalogDBControl.jcx
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/CatalogDBControl.jcx?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/CatalogDBControl.jcx
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/CatalogDBControl.jcx
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.controls.data;
+
+import java.sql.SQLException;
+import org.apache.beehive.samples.petstore.model.Category;
+import org.apache.beehive.samples.petstore.model.Item;
+import org.apache.beehive.samples.petstore.model.Product;
+import org.controlhaus.jdbc.JdbcControl;
+
+/**
+ * This control contains access to the pets database
+ */
+
[EMAIL PROTECTED]
+// PostgreSQL
+//@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/TestDB")
+
+//Derby
[EMAIL PROTECTED](databaseDriverClass="org.apache.derby.jdbc.EmbeddedDriver",
+ databaseURL="jdbc:derby:" + DBProperties.dbLocation +
"/petStoreDB;create=true")
+
+public interface CatalogDBControl extends JdbcControl {
+
+ // getCategory
+ @SQL(statement="select catId, name, description, image from Categories
where catId = {catId}")
+ public Category getCategory(String catId) throws SQLException;
+
+ // getCategoryList
+ @SQL(statement="select catId, name, description, image from Categories")
+ public Category[] getCategoryList() throws SQLException;
+
+ // getProductList
+ @SQL(statement="select productId, catId as category, name, description,
image from Products")
+ public Product[] getProductList() throws SQLException;
+
+ // getProductListByCategory
+ @SQL(statement="select productId, catId as category, name, description,
image from Products where catId = {catId}")
+ public Product[] getProductListByCategory(String catId) throws
SQLException;
+
+ // getProduct
+ @SQL(statement="select productId, catId as category, name, description,
image from Products where productId = {productId}")
+ public Product getProduct(String productId) throws SQLException;
+
+ // getItemListByProduct
+ @SQL(statement="select i.itemId, i.productId, i.status, i.attr1,
i.listPrice, i.unitCost, i.supplier, i.inventoryQuantity as Qty, p.name as
productName from Items i, Products p where i.productId = p.productId and
i.productId = {productId}")
+ public Item[] getItemListByProduct(String productId) throws SQLException;
+
+ // getItem
+ @SQL(statement="select i.itemId, i.productId, i.status, i.attr1,
i.listPrice, i.unitCost, i.supplier, i.inventoryQuantity as Qty, p.name as
productName from Items i, Products p where i.productId = p.productId and
i.itemId = {itemId}")
+ public Item getItem(String itemId) throws SQLException;
+
+ // updateItemQuantity
+ @SQL(statement="update Items set inventoryQuantity = {quantity} where
itemId = {itemId}")
+ public void updateItemQuantity(String itemId, int quantity) throws
SQLException;
+
+ // searchProductList
+ @SQL(statement="select p.productId, p.catId as category, p.name,
p.description, p.image from Products p, Categories c where p.catId = c.catId
and (p.name like {searchTerm} or p.description like {searchTerm} or c.name like
{searchTerm})")
+ public Product[] searchProductList(String searchTerm) throws SQLException;
+
+ // checkDB
+ @SQL(statement="select count(*) from sys.systables where
TABLENAME='CATEGORIES'")
+ public int checkDB() throws SQLException;
+
+ // initDB
+ @SQL(statement="{sql: initString}")
+ public void initDB(String initString) throws SQLException;
+}
\ No newline at end of file
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/CatalogDBControl.jcx
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/DBProperties.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/DBProperties.java?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/DBProperties.java
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/DBProperties.java
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.controls.data;
+
+public interface DBProperties {
+ public static final String dbLocation = "d:/Apache/Derby/petDB";
+}
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/DBProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/OrderDBControl.jcx
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/OrderDBControl.jcx?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/OrderDBControl.jcx
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/OrderDBControl.jcx
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.controls.data;
+
+import java.sql.SQLException;
+import org.apache.beehive.samples.petstore.model.Order;
+import org.apache.beehive.samples.petstore.model.OrderItem;
+import org.controlhaus.jdbc.JdbcControl;
+
+/**
+ * This control contains access to the pets database
+ */
+
[EMAIL PROTECTED]
+//PostgreSQL
+//@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/TestDB")
+
+//Derby
[EMAIL PROTECTED](databaseDriverClass="org.apache.derby.jdbc.EmbeddedDriver",
+ databaseURL="jdbc:derby:" + DBProperties.dbLocation +
"/petStoreDB;create=true")
+
+public interface OrderDBControl extends JdbcControl {
+
+ // addOrder
+ @SQL(statement="insert into orders (userId, totalPrice, creditCard, " +
+ "exprDate, cardType, status, shippingAddress, billingAddress)
values (" +
+ "{order.userId}, {order.totalPrice}, {order.creditCard}, " +
+ "{order.exprDate}, {order.cardType}, 'OK', " +
+ "{order.shippingAddress}, {order.billingAddress})")
+ public void addOrder(Order order) throws SQLException;
+
+ // getLastOrderIdForUser
+ @SQL(statement="select max(orderId) from Orders where userId =
{userId}")
+ public int getLastOrderIdForUser(String userId) throws SQLException;
+
+ // addOrderItem
+ @SQL(statement="insert into orderitems values ({orderId}, {itemId},
{quantity})")
+ public void addOrderItem(int orderId, String itemId, int quantity) throws
SQLException;
+
+ // getOrder
+ @SQL(statement="select orderId, userId, orderDate, totalPrice,
creditCard," +
+ "exprDate, cardType, status, shippingAddress, billingAddress
from Orders where " +
+ "orderId = {orderId} and userId = {userId}")
+ public Order getOrder(int orderId, String userId) throws SQLException;
+
+ // getOrderByUserId
+ @SQL(statement="select orderId, userId, orderDate, totalPrice,
creditCard," +
+ "exprDate, cardType, status, shippingAddress, billingAddress " +
+ "from Orders where userId = {userId}")
+ public Order[] getOrderByUserId(String userId) throws SQLException;
+
+ // getOrderItems
+ @SQL(statement="select o.itemId, productId, listPrice, unitCost, " +
+ "supplier, status, attr1, inventoryQuantity as Qty, o.quantity
" +
+ "from OrderItems o, Items i where o.orderId = {orderId} and
o.itemId = i.itemId")
+ public OrderItem[] getOrderItems(int orderId) throws SQLException;
+}
\ No newline at end of file
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/OrderDBControl.jcx
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.controls.exceptions;
+
+public class DataStoreException
+ extends Exception {
+
+ public DataStoreException(String message) {
+ super(message);
+ }
+}
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/NoSuchAddressException.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/NoSuchAddressException.java?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/NoSuchAddressException.java
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/NoSuchAddressException.java
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.controls.exceptions;
+
+public class NoSuchAddressException
+ extends Exception {
+
+ public NoSuchAddressException(String message) {
+ super(message);
+ }
+}
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/NoSuchAddressException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AccountForm.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AccountForm.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AccountForm.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AccountForm.java
Tue Apr 12 16:13:55 2005
@@ -20,7 +20,6 @@
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.beehive.samples.petstore.model.Account;
-import org.apache.beehive.samples.petstore.model.Address;
import javax.servlet.http.HttpServletRequest;
@@ -70,62 +69,6 @@
_account.setEmail(email);
}
- public String getPhone() {
- return _account.getPhone();
- }
-
- public void setPhone(String value) {
- _account.setPhone(value);
- }
-
- public String getAddr1() {
- return _account.getAddress().getAddr1();
- }
-
- public void setAddr1(String value) {
- _account.getAddress().setAddr1(value);
- }
-
- public String getAddr2() {
- return _account.getAddress().getAddr2();
- }
-
- public void setAddr2(String value) {
- _account.getAddress().setAddr2(value);
- }
-
- public String getCity() {
- return _account.getAddress().getCity();
- }
-
- public void setCity(String value) {
- _account.getAddress().setCity(value);
- }
-
- public String getState() {
- return _account.getAddress().getState();
- }
-
- public void setState(String value) {
- _account.getAddress().setState(value);
- }
-
- public String getZip() {
- return _account.getAddress().getZip();
- }
-
- public void setZip(String value) {
- _account.getAddress().setZip(value);
- }
-
- public String getCountry() {
- return _account.getAddress().getCountry();
- }
-
- public void setCountry(String value) {
- _account.getAddress().setCountry(value);
- }
-
public String getFavCategory() {
return _account.getFavCategory();
}
@@ -162,14 +105,6 @@
addErrorIfStringEmpty(errors, "firstName",
"account.error.firstName.required", _account.getFirstName());
addErrorIfStringEmpty(errors, "lastName",
"account.error.lastName.required", _account.getLastName());
addErrorIfStringEmpty(errors, "email", "account.error.email.required",
_account.getEmail());
- addErrorIfStringEmpty(errors, "phone", "account.error.phone.required",
_account.getPhone());
-
- Address address = _account.getAddress();
- addErrorIfStringEmpty(errors, "address1",
"account.error.address1.required", address.getAddr1());
- addErrorIfStringEmpty(errors, "city", "account.error.city.required",
address.getCity());
- addErrorIfStringEmpty(errors, "state", "account.error.state.required",
address.getState());
- addErrorIfStringEmpty(errors, "zip", "account.error.zip.required",
address.getZip());
- addErrorIfStringEmpty(errors, "country",
"account.error.country.required", address.getCountry());
return errors;
}
Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AddressForm.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AddressForm.java?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AddressForm.java
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AddressForm.java
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.forms;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionMapping;
+
+import org.apache.beehive.samples.petstore.model.Address;
+
+public abstract class AddressForm
+ extends AbstractPetstoreForm {
+
+ private Address _address;
+
+ public AddressForm() {
+ super();
+ }
+
+ public AddressForm(Address address) {
+ this();
+ _address = address;
+ }
+
+ protected Address getAddress() {
+ return _address;
+ }
+
+ public int getAddressId() {
+ return _address.getAddressId();
+ }
+
+ public void setAddressId(int addressId) {
+ _address.setAddressId(addressId);
+ }
+
+ public String getUserId() {
+ return _address.getUserId();
+ }
+
+ public String getName() {
+ return _address.getName();
+ }
+
+ public void setName(String name) {
+ _address.setName(name);
+ }
+
+ public String getAddr1() {
+ return _address.getAddr1();
+ }
+
+ public void setAddr1(String value) {
+ _address.setAddr1(value);
+ }
+
+ public String getAddr2() {
+ return _address.getAddr2();
+ }
+
+ public void setAddr2(String value) {
+ _address.setAddr2(value);
+ }
+
+ public String getCity() {
+ return _address.getCity();
+ }
+
+ public void setCity(String value) {
+ _address.setCity(value);
+ }
+
+ public String getState() {
+ return _address.getState();
+ }
+
+ public void setState(String value) {
+ _address.setState(value);
+ }
+
+ public String getZip() {
+ return _address.getZip();
+ }
+
+ public void setZip(String value) {
+ _address.setZip(value);
+ }
+
+ public String getCountry() {
+ return _address.getCountry();
+ }
+
+ public void setCountry(String value) {
+ _address.setCountry(value);
+ }
+
+ public String getPhone() {
+ return _address.getPhone();
+ }
+
+ public void setPhone(String value) {
+ _address.setPhone(value);
+ }
+
+ public ActionErrors baseValidate(ActionErrors errors, ActionMapping
mapping, HttpServletRequest request) {
+ addErrorIfStringEmpty(errors, "name", "address.error.name.required",
_address.getName());
+ addErrorIfStringEmpty(errors, "phone", "address.error.phone.required",
_address.getPhone());
+ addErrorIfStringEmpty(errors, "address1",
"address.error.address1.required", _address.getAddr1());
+ addErrorIfStringEmpty(errors, "city", "address.error.city.required",
_address.getCity());
+ addErrorIfStringEmpty(errors, "state", "address.error.state.required",
_address.getState());
+ addErrorIfStringEmpty(errors, "zip", "address.error.zip.required",
_address.getZip());
+ addErrorIfStringEmpty(errors, "country",
"address.error.country.required", _address.getCountry());
+
+ return errors;
+ }
+
+ public static final Address getAddress(AddressForm form) {
+ return form.getAddress();
+ }
+}
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/AddressForm.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/CheckoutForm.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/CheckoutForm.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/CheckoutForm.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/CheckoutForm.java
Tue Apr 12 16:13:55 2005
@@ -17,10 +17,9 @@
*/
package org.apache.beehive.samples.petstore.forms;
+import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
-import org.apache.beehive.samples.petstore.model.Account;
-import org.apache.beehive.samples.petstore.model.Address;
import org.apache.beehive.samples.petstore.model.Order;
import javax.servlet.http.HttpServletRequest;
@@ -28,17 +27,8 @@
public class CheckoutForm
extends OrderForm {
- private boolean _shippingAddressRequired;
private boolean _isCheckOut;
- public void setShippingAddressRequired(boolean shippingAddressRequired) {
- _shippingAddressRequired = shippingAddressRequired;
- }
-
- public boolean isShippingAddressRequired() {
- return _shippingAddressRequired;
- }
-
public boolean isCheckOut() {
return _isCheckOut;
}
@@ -51,36 +41,16 @@
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
Order order = getOrder();
ActionErrors errors = new ActionErrors();
- Account account = order.getAccount();
- addErrorIfStringEmpty(errors, "creditCart",
"order.error.creditCard.required", order.getCreditCard());
+ addErrorIfStringEmpty(errors, "creditCard",
"order.error.creditCard.required", order.getCreditCard());
addErrorIfStringEmpty(errors, "expirationDate",
"order.error.expirationDate.required", order.getExprDate());
addErrorIfStringEmpty(errors, "cardType",
"order.error.cardType.required", order.getCardType());
- Address billing = order.getBillingAddress();
- addErrorIfStringEmpty(errors, "billToFirstName",
"order.error.billToFirstName.required", billing.getFirstName());
- addErrorIfStringEmpty(errors, "billToLastName",
"order.error.billToLastName.required", billing.getLastName());
- addErrorIfStringEmpty(errors, "billToAddress1",
"order.error.billToAddress1.required", billing.getAddr1());
- addErrorIfStringEmpty(errors, "billToCity",
"order.error.billToCity.required", billing.getCity());
- addErrorIfStringEmpty(errors, "billToState",
"order.error.billToState.required", billing.getState());
- addErrorIfStringEmpty(errors, "billToZip",
"order.error.billToZip.required", billing.getZip());
- addErrorIfStringEmpty(errors, "billToCountry",
"order.error.billToCountry.required", billing.getCountry());
-
- if(isShippingAddressRequired()) {
- Address shipping = order.getShippingAddress();
- addErrorIfStringEmpty(errors, "shipToFirstName",
"order.error.shipToFirstName.required", shipping.getFirstName());
- addErrorIfStringEmpty(errors, "shipToLastName",
"order.error.shipToLastName.required", shipping.getLastName());
- addErrorIfStringEmpty(errors, "shipToAddress1",
"order.error.shipToAddress1.required", shipping.getAddr1());
- addErrorIfStringEmpty(errors, "shipToCity",
"order.error.shipToCity.required", shipping.getCity());
- addErrorIfStringEmpty(errors, "shipToState",
"order.error.shipToState.required", shipping.getState());
- addErrorIfStringEmpty(errors, "shipToZip",
"order.error.shipToZip.required", shipping.getZip());
- addErrorIfStringEmpty(errors, "shipToCountry",
"order.error.shipToCountry.required", shipping.getCountry());
- }
-
- // sets the ship address the same as the bill-to address
- if(!isShippingAddressRequired() && errors.size() > 0) {
- order.setShippingAddressIsBillingAddress(true);
- }
+ if (order.getBillingAddress() == -1)
+ errors.add("billingAddress", new
ActionError("order.error.billingAddress.required"));
+
+ if (order.getShippingAddress() == -1)
+ errors.add("shippingAddress", new
ActionError("order.error.shippingAddress.required"));
return errors;
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/OrderForm.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/OrderForm.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/OrderForm.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/forms/OrderForm.java
Tue Apr 12 16:13:55 2005
@@ -17,14 +17,14 @@
*/
package org.apache.beehive.samples.petstore.forms;
-import org.apache.beehive.netui.pageflow.FormData;
-
+import org.apache.beehive.samples.petstore.model.Cart;
import org.apache.beehive.samples.petstore.model.Order;
public class OrderForm
extends AbstractPetstoreForm {
private Order _order;
+ private Cart _cart;
public void setOrder(Order order) {
_order = order;
@@ -33,4 +33,13 @@
public Order getOrder() {
return _order;
}
+
+ public Cart getCart() {
+ return _cart;
+ }
+
+ public void setCart(Cart cart) {
+ _cart = cart;
+ }
+
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
Tue Apr 12 16:13:55 2005
@@ -26,17 +26,13 @@
private String _userId;
private String _password;
private String _email;
- private String _phone;
private String _firstName;
private String _lastName;
private String _status;
- private Address _address;
-
private String _favCategory;
private String _langPref;
private String _bannerData;
- private String _bannerName;
private boolean _myListOpt;
private boolean _bannerOpt;
@@ -51,14 +47,6 @@
_password = password;
}
- public Address getAddress() {
- return _address;
- }
-
- public void setAddress(Address address) {
- _address = address;
- }
-
public String getUserId() {
return _userId;
}
@@ -99,14 +87,6 @@
_status = status;
}
- public String getPhone() {
- return _phone;
- }
-
- public void setPhone(String phone) {
- _phone = phone;
- }
-
public void setFavCategory(String favCategory) {
_favCategory = favCategory;
}
@@ -115,7 +95,6 @@
return _favCategory;
}
-
public void setLangPref(String langPref) {
_langPref = langPref;
}
@@ -137,22 +116,42 @@
}
public void setMyListOpt(boolean myListOpt) {
- _myListOpt = myListOpt;
+ _myListOpt = myListOpt;
}
+ public int getMyListState() {
+ if (_myListOpt)
+ return 1;
+ else
+ return 0;
+ }
+
+ public void setMyListState(int myListOpt) {
+ if (myListOpt == 0)
+ _myListOpt = false;
+ else
+ _myListOpt = true;
+ }
+
public boolean isBannerOpt() {
return _bannerOpt;
}
public void setBannerOpt(boolean bannerOpt) {
- _bannerOpt = bannerOpt;
+ _bannerOpt = bannerOpt;
}
- public String getBannerName() {
- return _bannerName;
+ public int getBannerOptState() {
+ if (_bannerOpt)
+ return 1;
+ else
+ return 0;
}
- public void setBannerName(String bannerName) {
- _bannerName = bannerName;
+ public void setBannerOptState(int bannerOpt) {
+ if (bannerOpt == 0)
+ _bannerOpt = false;
+ else
+ _bannerOpt = true;
}
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Address.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Address.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Address.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Address.java
Tue Apr 12 16:13:55 2005
@@ -19,10 +19,11 @@
public class Address {
- private String _firstName;
- private String _lastName;
+ private int _addressId = -1;
+ private String _userId;
+ private String _name;
+ private String _phone;
- // shipping address
private String _addr1;
private String _addr2;
private String _city;
@@ -33,20 +34,28 @@
public Address() {
}
- public String getLastName() {
- return _lastName;
+ public int getAddressId() {
+ return _addressId;
}
- public void setLastName(String lastName) {
- _lastName = lastName;
+ public void setAddressId(int addressId) {
+ _addressId = addressId;
}
- public String getFirstName() {
- return _firstName;
+ public String getUserId() {
+ return _userId;
}
- public void setFirstName(String firstName) {
- _firstName = firstName;
+ public void setUserId(String userId) {
+ _userId = userId;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
}
public String getAddr1() {
@@ -95,5 +104,13 @@
public void setCountry(String country) {
_country = country;
+ }
+
+ public String getPhone() {
+ return _phone;
+ }
+
+ public void setPhone(String phone) {
+ _phone = phone;
}
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Item.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Item.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Item.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Item.java
Tue Apr 12 16:13:55 2005
@@ -25,23 +25,18 @@
public class Item
implements java.io.Serializable {
- private Product _product;
-
private String _itemId;
private String _productId;
private String _status;
private String _attr1;
- private String _attr2;
- private String _attr3;
- private String _attr4;
- private String _attr5;
private BigDecimal _listPrice;
private BigDecimal _unitCost;
private int _supplier;
private int _inventoryQuantity;
-
+ private String _productName;
+
public String getItemId() {
return _itemId;
}
@@ -58,14 +53,6 @@
return _inventoryQuantity;
}
- public Product getProduct() {
- return _product;
- }
-
- public void setProduct(Product product) {
- _product = product;
- }
-
public String getProductId() {
return _productId;
}
@@ -114,39 +101,16 @@
_attr1 = attr1;
}
- public String getAttr2() {
- return _attr2;
- }
-
- public void setAttr2(String attr2) {
- _attr2 = attr2;
- }
-
- public String getAttr3() {
- return _attr3;
- }
-
- public void setAttr3(String attr3) {
- _attr3 = attr3;
- }
-
- public String getAttr4() {
- return _attr4;
- }
-
- public void setAttr4(String attr4) {
- _attr4 = attr4;
+ public String toString() {
+ return "(" + getItemId().trim() + "-" + getProductId().trim() + ")";
}
-
- public String getAttr5() {
- return _attr5;
+
+ public String getProductName() {
+ return _productName;
}
- public void setAttr5(String attr5) {
- _attr5 = attr5;
+ public void setProductName(String productName) {
+ _productName = productName;
}
- public String toString() {
- return "(" + getItemId().trim() + "-" + getProductId().trim() + ")";
- }
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Order.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Order.java?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Order.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Order.java
Tue Apr 12 16:13:55 2005
@@ -23,36 +23,36 @@
public class Order
implements java.io.Serializable {
- private int _orderId;
+ private int _orderId = -1;
private Date _orderDate;
private Date _time;
- private String _courier;
+ //private String _courier;
private BigDecimal _totalPrice;
private String _creditCard;
private String _exprDate;
private String _cardType;
- private String _locale;
+ //private String _locale;
private String _status;
- private int _lineNum;
- private boolean _shippingAddressIsBillingAddress;
+ //private int _lineNum;
- private Account _account = null;
- private Cart _cart = null;
+ //private Account _account = null;
+ //private Cart _cart = null;
+ private String _userId;
- private Address _shippingAddress = null;
- private Address _billingAddress = null;
+ private int _shippingAddress = -1;
+ private int _billingAddress = -1;
- public Order(int orderId) {
- _orderId = orderId;
+ public void initOrder(String userId, Cart cart) {
+ _userId = userId;
+ _totalPrice = cart.getSubTotal();
}
-
- public void initOrder(Account account, Cart cart) {
+/*
+ public void initOrder(Account account, Cart cart) {
_account = account;
- _billingAddress = account.getAddress();
_cart = cart;
_orderDate = new Date();
_totalPrice = _cart.getSubTotal();
@@ -60,11 +60,11 @@
public Account getAccount() {
return _account;
- }
+ } */
- public Cart getCart() {
+ /* public Cart getCart() {
return _cart;
- }
+ }*/
public int getOrderId() {
return _orderId;
@@ -89,14 +89,14 @@
public void setTime(Date time) {
_time = time;
}
-
+/*
public String getCourier() {
return _courier;
}
public void setCourier(String courier) {
_courier = courier;
- }
+ } */
public BigDecimal getTotalPrice() {
return _totalPrice;
@@ -129,7 +129,7 @@
public void setCardType(String cardType) {
_cardType = cardType;
}
-
+/*
public String getLocale() {
return _locale;
}
@@ -137,7 +137,7 @@
public void setLocale(String locale) {
_locale = locale;
}
-
+*/
public String getStatus() {
return _status;
}
@@ -145,7 +145,7 @@
public void setStatus(String status) {
_status = status;
}
-
+/*
public int getLineNum() {
return _lineNum;
}
@@ -153,38 +153,31 @@
public void setLineNum(int lineNum) {
_lineNum = lineNum;
}
-
- public void setShippingAddressIsBillingAddress(boolean
shippingAddressIsBillingAddress) {
- _shippingAddressIsBillingAddress = shippingAddressIsBillingAddress;
- }
-
- public boolean getShippingAddressIsBillingAddress() {
- return _shippingAddressIsBillingAddress;
- }
-
- public Address getShippingAddress() {
- if(_shippingAddress == null)
- _shippingAddress = createAddress();
-
+*/
+ public int getShippingAddress() {
return _shippingAddress;
}
- public void setShippingAddress(Address shippingAddress) {
+ public void setShippingAddress(int shippingAddress) {
_shippingAddress = shippingAddress;
}
- public Address getBillingAddress() {
- if(_billingAddress == null)
- _billingAddress = createAddress();
-
+ public int getBillingAddress() {
return _billingAddress;
}
- public void setBillingAddress(Address billingAddress) {
+ public void setBillingAddress(int billingAddress) {
_billingAddress = billingAddress;
}
- private Address createAddress() {
- return new Address();
- }
+ public void setUserId(String userId) {
+ _userId = userId;
+ }
+
+ public String getUserId() {
+ return _userId;
+ }
+ //private Address createAddress() {
+ // return new Address();
+ //}
}
Added:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/OrderItem.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/OrderItem.java?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/OrderItem.java
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/OrderItem.java
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.samples.petstore.model;
+
+/**
+ *
+ */
+public class OrderItem
+ extends Item {
+
+ private int _quantity;
+
+ public int getQuantity() {
+ return _quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ _quantity = quantity;
+ }
+
+
+}
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/OrderItem.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/account.properties
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/account.properties?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/account.properties
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/account.properties
Tue Apr 12 16:13:55 2005
@@ -32,9 +32,18 @@
account.error.zip.required=ZIP is required.
account.error.country.required=Country is required.
+address.error.name.required=A name is required.
+address.error.phone.required=Phone number is required.
+address.error.address1.required=Address (1) is required.
+address.error.city.required=City is required.
+address.error.state.required=State is required.
+address.error.zip.required=ZIP is required.
+address.error.country.required=Country is required.
+
userInformation=User Information
usernameTaken=Sorry, this username is already taken. Please choose a
different one.
userIdLabel=User ID
passwordLabel=New Password
repeatPasswordLabel=Repeat Password
-listOrdersLabel=List Orders
\ No newline at end of file
+listOrdersLabel=List Orders
+listAddressesLabel=Add/Edit Addresses
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/order.properties
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/order.properties?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/order.properties
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/order.properties
Tue Apr 12 16:13:55 2005
@@ -2,6 +2,8 @@
order.error.creditCard.required=Fake credit card number required.
order.error.expirationDate.required=Expiration date is required.
order.error.cardType.required=Card type is required.
+order.error.shippingAddress.required=Shipping Address is Required.
+order.error.billingAddress.required=Billing Address is Required.
order.error.shipToFirstName.required=Shipping Address: first name is required.
order.error.shipToLastName.required=Shipping Address: last name is required.
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/view.properties
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/view.properties?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/view.properties
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/resources/view.properties
Tue Apr 12 16:13:55 2005
@@ -15,12 +15,16 @@
stateLabel=State
zipLabel=Zip
countryLabel=Country
+phoneLabel=Phone
+addressTypeLabel=Address Type
+
shipToDifferentAddressMessage=Ship to different address...
billingAddressLabel=Billing Address
shippingAddressLabel=Shipping Address
+newOrderLabel=New Order
orderNumberLabel=Order Number
-orderDateFormat=yyyy/MM/dd hh:mm:ss
+orderDateFormat=E, M dd, yyyy hh:mm a
orderStatus=Order Status
priceFormat=$#,##0.00
@@ -28,6 +32,10 @@
listPriceLabel=List Price
+addresses=Addresses
+addressType=Address Type
+address=Address
+
# these are duplicated with the account strings
itemIdLabel=Item ID
descriptionLabel=Description
@@ -40,6 +48,8 @@
shoppingCartLabel=Shopping Cart
checkoutSummaryLabel=Checkout Summary
+checkoutStep1=Billing & Shipping Information
+checkoutReturn=Return to Checkout
backOrderedMessage=Back Ordered
# need to use a message format here
@@ -91,4 +101,8 @@
signinLabel=Sign In
signoffLabel=Sign Out
searchLabel=Search
-myAccountLabel=My Account
\ No newline at end of file
+myAccountLabel=My Account
+
+adminTitle=Admin Tools for Local Host
+adminInit=Initialize the DB (recreates all tables and data)
+adminStop=Stop Derby DB (stops the DB to allow redeploy)
Added: incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/sql/initDB.sql
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/sql/initDB.sql?view=auto&rev=161136
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/sql/initDB.sql
(added)
+++ incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/sql/initDB.sql Tue
Apr 12 16:13:55 2005
@@ -0,0 +1,81 @@
+-- Drop existing tables in proper order
+drop table OrderItems;
+drop table Orders;
+drop table Addresses;
+drop table Accounts;
+drop table Items;
+drop table Products;
+drop table Categories;
+
+--- Create tables in proper order
+create table Categories(catId varchar(10) not null primary key, name
varchar(20) not null, image varchar(20) not null, description varchar(100) not
null);
+create table Products(productId varchar(10) not null primary key, catID
varchar(10) references Categories(catId) not null, name varchar(20) not null,
image varchar(30) not null, description varchar(100) not null);
+create table Items(itemId varchar(10) not null primary key, productId
varchar(10) references Products(productId) not null, listPrice numeric(8,2) not
null, unitCost numeric(8,2) not null, supplier int not null, status varchar(10)
not null, attr1 varchar(20), inventoryQuantity int not null);
+create table Accounts(userId varchar(20) not null primary key, password
varchar(20) not null, email varchar(50) not null, firstName varchar(20) not
null, lastName varchar(30) not null, status varchar(20) not null, favCategory
varchar(10) not null references Categories(catId), langPref varchar(20),
bannerData varchar(20), myListOpt smallint not null, bannerOpt smallint not
null);
+
+-- Derby Specific
+create table Addresses(addressId int not null GENERATED ALWAYS AS IDENTITY
primary key, userId varchar(20) references Accounts(userId) not null, name
varchar(100) not null, phone char(12) not null, addr1 varchar(100) not null,
addr2 varchar(100), city varchar(100) not null, state varchar(20) not null, zip
varchar(12) not null, country varchar(20) not null);
+create table Orders(orderId int not null GENERATED ALWAYS AS IDENTITY primary
key, userId varchar(20) references Accounts(userId), orderDate timestamp not
null DEFAULT current_timestamp, totalPrice numeric(8,2) not null, creditCard
varchar(20) not null, exprDate varchar(20) not null, cardType varchar(20) not
null, status varchar(10) not null, shippingAddress int references
Addresses(addressId) not null, billingAddress int references
Addresses(addressId) not null);
+
+-- PostgreSQL Specific
+-- create table Addresses(addressId serial primary key, userId varchar(20)
references Accounts(userId) not null, name varchar(100) not null, phone
char(12) not null, addr1 varchar(100) not null, addr2 varchar(100), city
varchar(100) not null, state varchar(20) not null, zip varchar(12) not null,
country varchar(20) not null);
+-- create table Orders(orderId serial primary key, userId varchar(20)
references Accounts(userId), orderDate timestamp not null DEFAULT
current_timestamp, totalPrice numeric(8,2) not null, creditCard varchar(20) not
null, exprDate varchar(20) not null, cardType varchar(20) not null, status
varchar(10) not null, shippingAddress int references Addresses(addressId) not
null, billingAddress int references Addresses(addressId) not null);
+
+create table OrderItems(orderId int not null references Orders(orderId),
itemId varchar(10) not null references Items(ItemId), quantity int not null,
primary key (orderId, itemId));
+
+-- Add data to tables
+insert into Categories values('FISH', 'Fish', 'fish_icon.gif', 'Saltwater,
Freshwater');
+insert into Categories values('DOGS', 'Dogs', 'dogs_icon.gif', 'Various
Breeds');
+insert into Categories values('REPTILES', 'Reptiles', 'reptiles_icon.gif',
'Lizards, Turtles, Snakes');
+insert into Categories values('CATS', 'Cats', 'cats_icon.gif', 'Various
Breeds, Exotic Varieties');
+insert into Categories values('BIRDS', 'Birds', 'birds_icon.gif', 'Exotic
Varieties');
+
+insert into Accounts (userId, password, email, firstName, lastName, status,
favCategory, langPref, bannerData, myListOpt, bannerOpt) values ('beehive',
'beehive', '[EMAIL PROTECTED]', 'Joe', 'User', 'OK', 'DOGS', 'ENGLISH', '', 1,
1);
+
+insert into Addresses (name, userId, addr1, addr2, city, state, zip, country,
phone) values ('Home', 'beehive', '901 San Antonio Road', 'MS UCUP02-206',
'Palo Alto', 'CA', '94303', 'USA', '555-555-5555');
+
+insert into Products values ('AV-CB-01', 'BIRDS', 'Amazon Parrot',
'bird2.jpg', 'Great companion for up to 75 years');
+insert into Products values ('AV-SB-02', 'BIRDS', 'Finch', 'bird1.jpg', 'Great
stress reliever');
+insert into Products values ('FI-FW-01', 'FISH', 'Koi', 'fish3.jpg', 'Fresh
Water fish from Japan');
+insert into Products values ('FI-FW-02', 'FISH', 'Goldfish', 'fish2.jpg',
'Fresh Water fish from China');
+insert into Products values ('FI-SW-01', 'FISH', 'Angelfish', 'fish1.jpg',
'Salt Water fish from Australia');
+insert into Products values ('FI-SW-02', 'FISH', 'Tiger Shark', 'fish4.jpg',
'Salt Water fish from Australia');
+insert into Products values ('FL-DLH-02', 'CATS', 'Persian', 'cat1.jpg',
'Friendly house cat, doubles as a princess');
+insert into Products values ('FL-DSH-01', 'CATS', 'Manx', 'cat2.jpg', 'Great
for reducing mouse populations');
+insert into Products values ('K9-BD-01', 'DOGS', 'Bulldog', 'dog1.jpg',
'Friendly dog from England');
+insert into Products values ('K9-CW-01', 'DOGS', 'Chihuahua', 'dog2.jpg',
'Great companion dog');
+insert into Products values ('K9-DL-01', 'DOGS', 'Dalmation', 'dog3.jpg',
'Great dog for a Fire Station');
+insert into Products values ('K9-PO-02', 'DOGS', 'Poodle', 'dog6.jpg', 'Cute
dog from France');
+insert into Products values ('K9-RT-01', 'DOGS', 'Golden Retriever',
'dog4.jpg', 'Great family dog');
+insert into Products values ('K9-RT-02', 'DOGS', 'Labrador Retriever',
'dog5.jpg', 'Great hunting dog');
+insert into Products values ('RP-LI-02', 'REPTILES', 'Iguana', 'lizard1.jpg',
'Friendly green friend');
+insert into Products values ('RP-SN-01', 'REPTILES', 'Rattlesnake',
'snake1.jpg', 'Doubles as a watch dog');
+
+insert into Items values ('EST-1', 'FI-SW-01', 16.50, 10.00, 1, 'P', 'Large',
10000);
+insert into Items values ('EST-2', 'FI-SW-01', 16.50, 10.00, 1, 'P', 'Small',
10000);
+insert into Items values ('EST-3', 'FI-SW-02', 18.50, 12.00, 1, 'P',
'Toothless', 10000);
+insert into Items values ('EST-4', 'FI-FW-01', 18.50, 12.00, 1, 'P',
'Spotted', 10000);
+insert into Items values ('EST-5', 'FI-FW-01', 18.50, 12.00, 1, 'P',
'Spotless', 10000);
+insert into Items values ('EST-6', 'K9-BD-01', 18.50, 12.00, 1, 'P', 'Male
Adult', 10000);
+insert into Items values ('EST-7', 'K9-BD-01', 18.50, 12.00, 1, 'P', 'Female
Puppy', 10000);
+insert into Items values ('EST-8', 'K9-PO-02', 18.50, 12.00, 1, 'P', 'Male
Puppy', 10000);
+insert into Items values ('EST-9', 'K9-DL-01', 18.50, 12.00, 1, 'P', 'Spotless
Male Puppy', 10000);
+insert into Items values ('EST-10', 'K9-DL-01', 18.50, 12.00, 1, 'P', 'Spotted
Adult Female', 10000);
+insert into Items values ('EST-11', 'RP-SN-01', 18.50, 12.00, 1, 'P',
'Venomless', 10000);
+insert into Items values ('EST-12', 'RP-SN-01', 18.50, 12.00, 1, 'P',
'Rattleless', 10000);
+insert into Items values ('EST-13', 'RP-LI-02', 18.50, 12.00, 1, 'P', 'Green
Adult', 10000);
+insert into Items values ('EST-14', 'FL-DSH-01', 58.50, 12.00, 1, 'P',
'Tailless', 10000);
+insert into Items values ('EST-15', 'FL-DSH-01', 23.50, 12.00, 1, 'P', 'With
tail', 10000);
+insert into Items values ('EST-16', 'FL-DLH-02', 93.50, 12.00, 1, 'P', 'Adult
Female', 10000);
+insert into Items values ('EST-17', 'FL-DLH-02', 93.50, 12.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-18', 'AV-CB-01', 193.50, 92.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-19', 'AV-SB-02', 15.50, 2.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-20', 'FI-FW-02', 5.50, 2.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-21', 'FI-FW-02', 5.29, 1.00, 1, 'P', 'Adult
Female', 10000);
+insert into Items values ('EST-22', 'K9-RT-02', 135.50, 100.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-23', 'K9-RT-02', 145.49, 100.00, 1, 'P', 'Adult
Female', 10000);
+insert into Items values ('EST-24', 'K9-RT-02', 255.50, 92.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-25', 'K9-RT-02', 325.29, 90.00, 1, 'P', 'Adult
Female', 10000);
+insert into Items values ('EST-26', 'K9-CW-01', 125.50, 92.00, 1, 'P', 'Adult
Male', 10000);
+insert into Items values ('EST-27', 'K9-CW-01', 155.29, 90.00, 1, 'P', 'Adult
Female', 10000);
+insert into Items values ('EST-28', 'K9-RT-01', 155.29, 90.00, 1, 'P', 'Adult
Female', 10000);
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/accountFields.tag
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/accountFields.tag?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/accountFields.tag
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/accountFields.tag
Tue Apr 12 16:13:55 2005
@@ -16,7 +16,7 @@
<tr class="rowyellow">
<td class="celldata"><netui:span
value="${bundle.default.firstName}:"/></td>
<td class="celldata">
- <netui:textBox dataSource="actionForm.firstName"/>
+ <netui:textBox dataSource="pageInput.actionForm.firstName"/>
<br/>
<netui:error key="firstName"/>
</td>
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/footer.tag
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/footer.tag?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/footer.tag
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/footer.tag
Tue Apr 12 16:13:55 2005
@@ -4,14 +4,14 @@
<%@ tag body-content="empty" %>
<%@ attribute name="contextPath" required="true" %>
-<c:if test="${sharedFlow.account != null && sharedFlow.account.bannerOpt ==
true}">
+<c:if test="${sharedFlow.rootSharedFlow.account != null &&
sharedFlow.rootSharedFlow.account.bannerOpt == true}">
<p>
<table background="${pageContext.request.contextPath}/images/bkg-topbar.gif"
border="0" cellspacing="0" cellpadding="5" width="100%">
<tbody>
<tr>
<td width="100%">
<center>
- <netui:image border="0"
src="${pageContext.request.contextPath}/images/${sharedFlow.account.bannerName}"/>
+ <netui:image border="0"
src="${pageContext.request.contextPath}/images/banner_${sharedFlow.rootSharedFlow.account.favCategory}.gif"/>
</center>
</td>
</tr>
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/headerMenu.tag
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/headerMenu.tag?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/headerMenu.tag
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/headerMenu.tag
Tue Apr 12 16:13:55 2005
@@ -22,7 +22,7 @@
<netui:imageAnchor action="rootSharedFlow.globalViewCart" border="0"
src="${contextPath}/images/cart.gif"/>
<netui:image border="0" src="${contextPath}/images/separator.gif"/>
<c:choose>
- <c:when test="${sharedFlow.account == null}">
+ <c:when test="${sharedFlow.rootSharedFlow.account == null}">
<%-- sharedFlow.signon --%>
<netui:anchor styleClass="boldanchor" action="rootSharedFlow.signon">
Sign In
@@ -33,8 +33,8 @@
<netui:anchor styleClass="boldanchor"
action="rootSharedFlow.signoff">
Sign Out
</netui:anchor>
- <netui:image border="0"
src="${pageContext.request.contextPath}/images/separator.gif"/>
- <netui:anchor styleClass="boldanchor" action="globalEditAccount">
+ <netui:image border="0" src="${contextPath}/images/separator.gif"/>
+ <netui:anchor styleClass="boldanchor"
action="rootSharedFlow.globalEditAccount">
My Account
</netui:anchor>
</c:otherwise>
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/orderSummary.tag
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/orderSummary.tag?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/orderSummary.tag
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/orderSummary.tag
Tue Apr 12 16:13:55 2005
@@ -3,7 +3,7 @@
<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0"
prefix="netui-data"%>
<%@ tag body-content="empty" %>
-<%@ attribute name="order" required="false"
type="org.apache.beehive.samples.petstore.model.Order"%>
+
<%--
This tag also implicitly expects that the "actionForm" and "bundle"
objects are passed in explicitly.
@@ -15,11 +15,18 @@
<table class="tablegreen" width="60%" align="center">
<tr class="rowyellow">
<td align="center" colspan="2">
- <netui:span styleClass="boldlabel"
value="${bundle.view.orderNumberLabel} ${order.orderId}"/>
- <br/>
- <netui:span styleClass="boldlabel" value="${order.orderDate}">
- <netui:formatDate pattern="${bundle.view.orderDateFormat}"/>
- </netui:span>
+ <c:choose>
+ <c:when test="${pageInput.order.orderId != -1}">
+ <netui:span styleClass="boldlabel"
value="${bundle.view.orderNumberLabel} ${pageInput.order.orderId}"/>
+ <br/>
+ <netui:span styleClass="boldlabel"
value="${pageInput.order.orderDate}">
+ <netui:formatDate pattern="${bundle.view.orderDateFormat}"/>
+ </netui:span>
+ </c:when>
+ <c:otherwise>
+ <netui:span styleClass="boldlabel"
value="${bundle.view.newOrderLabel}" />
+ </c:otherwise>
+ </c:choose>
</td>
</tr>
<tr class="rowyellow">
@@ -30,105 +37,90 @@
<tr class="rowyellow">
<td class="celldata">${bundle.view.cardTypeLabel}:</td>
<td class="celldata">
- <netui:span value="${order.cardType}"/>
+ <netui:span value="${pageInput.order.cardType}"/>
</td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.cardNumberLabel}:</td>
- <td class="celldata"><netui:span value="${order.creditCard}"/>
- <netui:span styleClass="error" value="* Fake number!"/>
- </td>
+ <td class="celldata"><netui:span
value="${pageInput.order.creditCard}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.expirationDateLabel}:</td>
- <td class="celldata"><netui:span value="${order.exprDate}"/></td>
+ <td class="celldata"><netui:span value="${pageInput.order.exprDate}"/></td>
</tr>
<tr class="rowyellow">
<td colspan="2">
- <netui:span styleClass="greenboldlabel"
value="${bundle.view.billingAddressLabel}"/>
+ <netui:span styleClass="boldlabel"
value="${bundle.view.billingAddressLabel}"/>
</td>
</tr>
<tr class="rowyellow">
- <td class="celldata">${bundle.view.firstNameLabel}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.firstName}"/></td>
- </tr>
- <tr class="rowyellow">
- <td class="celldata">${bundle.view.lastNameLabel}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.lastName}"/></td>
+ <td class="celldata">${bundle.view.nameLabel}:</td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.name}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.address1Label}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.addr1}"/></td>
- </tr>
- <tr class="rowyellow">
- <td class="celldata">${bundle.view.address2Label}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.addr2}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.addr1}"/></td>
</tr>
+ <c:if test="${pageInput.billingAddress.addr2} != ''">
+ <tr class="rowyellow">
+ <td class="celldata">${bundle.view.address2Label}:</td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.addr2}"/></td>
+ </tr>
+ </c:if>
<tr class="rowyellow">
<td class="celldata">${bundle.view.cityLabel}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.city}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.city}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.stateLabel}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.state}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.state}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.zipLabel}:</td>
- <td class="celldata"><netui:span value="${order.billingAddress.zip}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.zip}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.countryLabel}:</td>
- <td class="celldata"><netui:span
value="${order.billingAddress.country}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.billingAddress.country}"/></td>
</tr>
<tr class="rowyellow">
<td colspan="2">
<netui:span styleClass="boldlabel"
value="${bundle.view.shippingAddressLabel}"/>
</td>
</tr>
- <c:choose>
- <c:when test="${order.shippingAddressIsBillingAddress == false}">
- <tr class="rowyellow">
- <td class="celldata">${bundle.view.firstNameLabel}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.firstName}"/></td>
- </tr>
<tr class="rowyellow">
- <td class="celldata">${bundle.view.lastNameLabel}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.lastName}"/></td>
+ <td class="celldata">${bundle.view.nameLabel}:</td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.name}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.address1Label}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.addr1}"/></td>
- </tr>
- <tr class="rowyellow">
- <td class="celldata">${bundle.view.address2Label}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.addr2}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.addr1}"/></td>
</tr>
+ <c:if test="${pageInput.shippingAddress.addr2} != ''">
+ <tr class="rowyellow">
+ <td class="celldata">${bundle.view.address2Label}:</td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.addr2}"/></td>
+ </tr>
+ </c:if>
<tr class="rowyellow">
<td class="celldata">${bundle.view.cityLabel}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.city}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.city}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.stateLabel}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.state}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.state}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.zipLabel}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.zip}"/></td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.zip}"/></td>
</tr>
<tr class="rowyellow">
<td class="celldata">${bundle.view.countryLabel}:</td>
- <td class="celldata"><netui:span
value="${order.shippingAddress.country}"/></td>
- </tr>
- </c:when>
- <c:otherwise>
- <tr class="rowyellow">
- <td class="celldata" colspan="2">Use Billing Address.</td>
+ <td class="celldata"><netui:span
value="${pageInput.shippingAddress.country}"/></td>
</tr>
- </c:otherwise>
- </c:choose>
<tr class="rowyellow">
<td colspan="2">
- <netui:span styleClass="greenboldlabel"
value="${bundle.view.orderStatus} ${order.status}"/>
+ <netui:span styleClass="greenboldlabel"
value="${bundle.view.orderStatus} ${pageInput.order.status}"/>
</td>
</tr>
<tr>
@@ -141,7 +133,7 @@
<td class="celldata"><b>${bundle.view.unitPriceLabel}</b></td>
<td class="celldata"><b>${bundle.view.totalCostLabel}</b></td>
</tr>
- <netui-data:repeater dataSource="pageInput.order.cart.lineItems">
+ <netui-data:repeater dataSource="pageInput.lineItems">
<tr class="rowyellow">
<td class="celldata"><b>
<c:choose>
@@ -159,11 +151,7 @@
</td>
<td class="celldata">
<netui:span value="${container.item.item.attr1}"/>
- <netui:span value="${container.item.item.attr2}"/>
- <netui:span value="${container.item.item.attr3}"/>
- <netui:span value="${container.item.item.attr4}"/>
- <netui:span value="${container.item.item.attr5}"/>
- <netui:span value="${container.item.item.product.name}"/>
+ <netui:span value="${container.item.item.productName}"/>
</td>
<td align="center">
<netui:span value="${container.item.quantity}"/>
@@ -183,7 +171,7 @@
<tr class="rowyellow">
<td colspan="6" align="right">
<b>${bundle.view.totalCostLabel}:
- <netui:span value="${order.totalPrice}">
+ <netui:span value="${pageInput.order.totalPrice}">
<netui:formatNumber pattern="${bundle.view.priceFormat}"/>
</netui:span>
</b><br/>
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/productFavorites.tag
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/productFavorites.tag?view=diff&r1=161135&r2=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/productFavorites.tag
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/tags/beehive/petstore/productFavorites.tag
Tue Apr 12 16:13:55 2005
@@ -17,7 +17,7 @@
</tr>
<tr class="rowyellow">
<td>
- <netui-data:repeater dataSource="sharedFlow.myList">
+ <netui-data:repeater dataSource="sharedFlow.rootSharedFlow.myList">
<netui:anchor action="viewProduct">
<netui:parameter name="productId"
value="${container.item.productId}"/>
<netui:span value="${container.item.name}"/>
Added:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package account.addresses;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionMapping;
+
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.samples.petstore.controls.AddressControl;
+import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
+import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAddressException;
+import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
+import org.apache.beehive.samples.petstore.forms.AddressForm;
+import org.apache.beehive.samples.petstore.model.Address;
+
[EMAIL PROTECTED](
+ sharedFlowRefs = {
+ @Jpf.SharedFlowRef(name = "rootSharedFlow", type =
webappRoot.SharedFlow.class)
+ },
+ messageBundles = [EMAIL PROTECTED](bundlePath =
"org.apache.beehive.samples.petstore.resources.account")}
+)
+public class Controller
+ extends PageFlowController {
+
+ @Control()
+ private AddressControl _addressControl;
+
+ @Jpf.SharedFlowField(name = "rootSharedFlow")
+ private webappRoot.SharedFlow _sharedFlow = null;
+
+ private CreateAddressForm _createForm = null;
+
+ // begin - show list of addresses
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward(name = "success", path = "listAddresses.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name = "addresses",
+ type = Address[].class,
+ required = true)
+ })
+ }
+ )
+ protected Forward begin() throws DataStoreException {
+
+ _sharedFlow.ensureLogin();
+ Forward forward = new Forward("success");
+ forward.addActionOutput("addresses",
_addressControl.getUserAddresses(_sharedFlow.getAccount().getUserId()));
+ return forward;
+ }
+
+ // createUpdateAddress - get new/existing address and display on
createUpdate page
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward(name = "success", path = "createUpdate.jsp")
+ }
+ )
+ protected Forward createUpdateAddress() throws DataStoreException,
InvalidIdentifierException
+ {
+ _sharedFlow.ensureLogin();
+
+ // If an addressId is passed in, this is an edit of an existing
address
+ String addressId = getRequest().getParameter("addressId");
+ Address address;
+
+ if (addressId == null)
+ {
+ // New address
+ address = new Address();
+ address.setUserId(_sharedFlow.getAccount().getUserId());
+ } else {
+ // Existing address
+ address =
_addressControl.getAddress(Integer.parseInt(addressId));
+ }
+
+ _createForm = new CreateAddressForm(address);
+ Forward forward = new Forward("success", _createForm);
+ return forward;
+ }
+
+ // updateAddress - Insert/update new or existing address
+ @Jpf.Action(
+ useFormBean = "_createForm",
+ forwards = {
+ @Jpf.Forward(name = "success", action = "begin")
+ }, validationErrorForward = @Jpf.Forward(name = "failure",
navigateTo = Jpf.NavigateTo.currentPage)
+ )
+ protected Forward updateAddress(CreateAddressForm form)
+ throws InvalidIdentifierException, NoSuchAddressException,
DataStoreException
+ {
+ _sharedFlow.ensureLogin();
+
+ Address address = AddressForm.getAddress(form);
+
+ if (address.getAddressId() == -1)
+ {
+ // Add New Address
+ _addressControl.insertAddress(address);
+ } else {
+ // Update Existing Address
+ _addressControl.updateAddress(address);
+ }
+
+ return new Forward("success");
+ }
+
+ // deleteAddress - delete a user's address
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward(name = "success", action = "begin")
+ }
+ )
+ protected Forward deleteAddress() throws DataStoreException,
InvalidIdentifierException, NoSuchAddressException
+ {
+ _sharedFlow.ensureLogin();
+
+ String addressId = getRequest().getParameter("addressId");
+
+ // Will only delete the address if the user owns it
+ _addressControl.deleteAddress(Integer.parseInt(addressId),
_sharedFlow.getAccount().getUserId());
+
+ return new Forward("success");
+ }
+
+ public static class CreateAddressForm
+ extends AddressForm {
+
+ public CreateAddressForm() {
+ super();
+ }
+
+ public CreateAddressForm(Address address) {
+ super(address);
+ }
+
+ public void setUserId(String userId) {
+ getAddress().setUserId(userId);
+ }
+
+ public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
+ ActionErrors errors = new ActionErrors();
+ Address address = getAddress();
+
+ addErrorIfStringEmpty(errors, "userId",
"address.error.userid.required", address.getUserId());
+
+ baseValidate(errors, mapping, request);
+
+ return errors;
+ }
+ }
+}
\ No newline at end of file
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/createUpdate.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/addresses/createUpdate.jsp?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/createUpdate.jsp
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/createUpdate.jsp
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,118 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0"
prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0"
prefix="netui-template"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib prefix="beehive-petstore" tagdir="/WEB-INF/tags/beehive/petstore" %>
+
+<netui-data:declareBundle
bundlePath="org.apache.beehive.samples.petstore.resources.view" name="view"/>
+
+<netui-template:template templatePage="/site/template.jsp">
+ <netui-template:section name="leftnav">
+
+ </netui-template:section>
+ <netui-template:section name="body">
+ <netui:errors/>
+ <netui:form action="updateAddress">
+ <netui:hidden dataSource="actionForm.userId" />
+ <netui:hidden dataSource="actionForm.addressId" />
+ <center>
+ <table cellpadding=10 cellspacing=0 align=center border=1
bgcolor=#dddddd>
+ <tr>
+ <td>
+ <netui:span styleClass="boldlabel"
value="${bundle.view.address}"/>
+ <table bgcolor="#008800" border=0 cellpadding=3 cellspacing=1>
+ <tr class="rowyellow">
+ <td>${bundle.view.nameLabel}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.name"/>
+ <br/>
+ <netui:error key="name"/>
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.address1Label}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.addr1" />
+ <br/>
+ <netui:error key="address1"/>
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.address2Label}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.addr2" />
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.cityLabel}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.city" />
+ <br/>
+ <netui:error key="city"/>
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.stateLabel}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.state" />
+ <br/>
+ <netui:error key="state"/>
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.zipLabel}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.zip" />
+ <br/>
+ <netui:error key="zip"/>
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.countryLabel}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.country" />
+ <br/>
+ <netui:error key="country"/>
+ </td>
+ </tr>
+ <tr class="rowyellow">
+ <td>${bundle.view.phoneLabel}:
+ </td>
+ <td>
+ <netui:textBox dataSource="actionForm.phone" />
+ <br/>
+ <netui:error key="phone"/>
+ </td>
+ </tr>
+ </td>
+ </tr>
+ </table>
+ <br/>
+ <CENTER>
+ <c:choose>
+ <c:when test="${actionForm.addressId == -1}">
+ <netui:imageButton
src="${pageContext.request.contextPath}/images/insert.gif"/>
+ </c:when>
+ <c:otherwise>
+ <netui:imageButton
src="${pageContext.request.contextPath}/images/update.gif"/>
+ </c:otherwise>
+ </c:choose>
+
+ <netui:imageAnchor action="begin" border="0"
src="${pageContext.request.contextPath}/images/cancel.gif" />
+ </CENTER>
+ </td>
+ </tr>
+ </table>
+ </center>
+ </netui:form>
+
+ </netui-template:section>
+</netui-template:template>
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/createUpdate.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/listAddresses.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/addresses/listAddresses.jsp?view=auto&rev=161136
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/listAddresses.jsp
(added)
+++
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/listAddresses.jsp
Tue Apr 12 16:13:55 2005
@@ -0,0 +1,77 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0"
prefix="netui-data"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0"
prefix="netui-template"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+
+<netui-data:declarePageInput name="addresses"
type="org.apache.beehive.samples.petstore.model.address[]" required="true"/>
+
+<script language="javascript">
+ function VerifyDelete(sName, nID)
+ {
+ if (confirm('Delete address named ' + sName + '?'))
+ window.location.href =
'${pageContext.request.contextPath}/account/addresses/deleteAddress.do?addressId='
+ nID;
+ }
+</script>
+
+<netui-template:template templatePage="/site/template.jsp">
+ <netui-template:section name="leftnav"> </netui-template:section>
+
+ <netui-template:section name="body">
+ <netui-data:declareBundle
bundlePath="org.apache.beehive.samples.petstore.resources.view" name="view"/>
+ <center>
+ <table cellpadding="10" cellspacing="0" align="center" bgcolor="#dddddd">
+ <tr>
+ <td>
+ <netui:span styleClass="boldlabel"
value="${bundle.view.addresses}"/>
+ <netui-data:repeater
dataSource="pageInput.addresses" defaultText="<br/><br/>No addresses
found<br/><br/>">
+ <netui-data:repeaterHeader>
+ <table class="tablegreen">
+ </netui-data:repeaterHeader>
+ <netui-data:repeaterItem>
+ <tr valign="top" class="rowyellow">
+ <td class="celldata">
+ <netui:span
value="${container.item.name}" /><br/>
+ <netui:span
value="${container.item.addr1}" /><br/>
+ <netui:span
value="${container.item.addr2}" />
+ <c:if test="${container.item.addr2
!= ''}">
+ <br/>
+ </c:if>
+ <netui:span
value="${container.item.city}" />,
+ <netui:span
value="${container.item.state}" />
+ <netui:span
value="${container.item.zip}" /><br/>
+ <netui:span
value="${container.item.country}" /><br/>
+ <netui:span
value="${container.item.phone}" /><br/>
+ <center>
+ <netui:imageAnchor
action="createUpdateAddress" border="0"
src="${pageContext.request.contextPath}/images/edit.gif">
+ <netui:parameter
name="addressId" value="${container.item.addressId}"/>
+
</netui:imageAnchor>
+ <a
href="javascript:VerifyDelete('${container.item.name}',
${container.item.addressId});"><img border="0"
src="${pageContext.request.contextPath}/images/delete.gif"/></a>
+ </center>
+ </td>
+ </tr>
+ </netui-data:repeaterItem>
+ <netui-data:repeaterFooter>
+ </table>
+ </netui-data:repeaterFooter>
+ </netui-data:repeater>
+ <br/>
+ <center>
+ <netui:imageAnchor action="createUpdateAddress"
border="0" src="${pageContext.request.contextPath}/images/insert.gif" />
+ <br/>
+ <br/>
+ <c:if test="${sharedFlow.rootSharedFlow.account.status
== 'checking_out'}">
+ <netui:anchor
action="rootSharedFlow.globalCheckOut.do">
+ <b>${bundle.view.checkoutReturn}</b>
+ </netui:anchor><br/>
+ </c:if>
+ <netui:anchor
action="rootSharedFlow.globalEditAccount.do">
+ <b>${bundle.view.myAccountLabel}</b>
+ </netui:anchor>
+ </center>
+ </td>
+ </tr>
+ </table>
+ </center>
+ </netui-template:section>
+</netui-template:template>
Propchange:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/listAddresses.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf?view=diff&r1=161135&r2=161136
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
(original)
+++ incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
Tue Apr 12 16:13:55 2005
@@ -30,13 +30,13 @@
import org.apache.beehive.samples.petstore.controller.AccountController;
import org.apache.beehive.samples.petstore.controls.AccountControl;
import org.apache.beehive.samples.petstore.controls.CatalogControl;
+import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAccountException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.AccountAlreadyExistsException;
import
org.apache.beehive.samples.petstore.controls.exceptions.UserAlreadyExistsException;
import org.apache.beehive.samples.petstore.forms.AccountForm;
import org.apache.beehive.samples.petstore.model.Account;
-import org.apache.beehive.samples.petstore.model.Address;
@Jpf.Controller(
sharedFlowRefs = {
@@ -87,8 +87,6 @@
)
protected Forward viewCreateAccount() {
Account account = new Account();
- account.setAddress(new Address());
-
_createForm = new CreateAccountForm(account);
Forward forward = new Forward("success", _createForm);
@@ -106,8 +104,8 @@
},
validationErrorForward = @Jpf.Forward(name = "failure", navigateTo
= Jpf.NavigateTo.currentPage)
)
- protected Forward createAccount(CreateAccountForm form)
- throws AccountAlreadyExistsException, InvalidIdentifierException,
UserAlreadyExistsException, NoSuchAccountException {
+ protected Forward createAccount(CreateAccountForm form)
+ throws AccountAlreadyExistsException, InvalidIdentifierException,
UserAlreadyExistsException, NoSuchAccountException, DataStoreException {
// ensure unique user name
_isUsernameTaken = false;
if(_accountControl.checkAccountExists(form.getUserId())) {