From 48805699eb011bd2f946f5189024a2975f8072ff Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Sat, 17 Feb 2007 21:10:50 +0000 Subject: [PATCH] Cleanup of the sellitem-jsf sample application. --- .../sellitem/InMemoryDatabaseCreator.java | 4 +++- .../samples/sellitem/JdbcSaleProcessor.java | 1 + .../webflow/samples/sellitem/SaleValidator.java | 11 ++++------- .../src/main/webapp/WEB-INF/faces-config.xml | 2 +- .../sellitem-jsf/src/main/webapp/error.jsp | 17 ----------------- 5 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 spring-webflow-samples/sellitem-jsf/src/main/webapp/error.jsp diff --git a/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/InMemoryDatabaseCreator.java b/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/InMemoryDatabaseCreator.java index 84f0937a..baafe632 100644 --- a/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/InMemoryDatabaseCreator.java +++ b/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/InMemoryDatabaseCreator.java @@ -21,7 +21,9 @@ public class InMemoryDatabaseCreator extends JdbcDaoSupport { @Override protected void initDao() throws Exception { - String createSales = "create table T_SALES (ID int not null identity primary key, ITEM_COUNT int not null, PRICE double NOT NULL, category VARCHAR(1) NOT NULL, SHIPPING_TYPE varchar(1))"; + String createSales = + "create table T_SALES (ID int not null identity primary key, ITEM_COUNT int not null, " + + "PRICE double NOT NULL, category VARCHAR(1) NOT NULL, SHIPPING_TYPE varchar(1))"; getJdbcTemplate().execute(createSales); } diff --git a/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/JdbcSaleProcessor.java b/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/JdbcSaleProcessor.java index c3e245ec..b0506d87 100644 --- a/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/JdbcSaleProcessor.java +++ b/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/JdbcSaleProcessor.java @@ -18,6 +18,7 @@ package org.springframework.webflow.samples.sellitem; import org.springframework.jdbc.core.support.JdbcDaoSupport; public class JdbcSaleProcessor extends JdbcDaoSupport implements SaleProcessor { + public void process(Sale sale) { getJdbcTemplate() .update("insert into T_SALES values (?, ?, ?, ?, ?)", diff --git a/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/SaleValidator.java b/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/SaleValidator.java index 0966cab0..f6878952 100644 --- a/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/SaleValidator.java +++ b/spring-webflow-samples/sellitem-jsf/src/main/java/org/springframework/webflow/samples/sellitem/SaleValidator.java @@ -30,9 +30,8 @@ public class SaleValidator implements Validator { } public void validatePriceAndItemCount(Sale sale, Errors errors) { - // the next two items are normallhy more appropriately handled by JSF - // field - // validation. We'll leave them here for safety + // the next two items are normally more appropriately handled by JSF + // field validation. We'll leave them here for safety if (sale.getItemCount() <= 0) { errors.rejectValue("itemCount", "tooLittle", "Item count must be greater than 0"); } @@ -40,11 +39,9 @@ public class SaleValidator implements Validator { errors.rejectValue("price", "tooLittle", "Price must be greater than 0.0"); } - // perhaps an artificial example, but we want to show that in the JSF - // integration + // perhaps an artificial example, but we want to show that in the JSF integration // validators are best used for validation of field relationships. - // Individual fields - // are better validated with simple JSF field validation + // Individual fields are better validated with simple JSF field validation if (sale.getItemCount() * sale.getPrice() > 1000000) errors.reject("saleTooLarge", "total dollar value for sale above allowed limit"); } diff --git a/spring-webflow-samples/sellitem-jsf/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/sellitem-jsf/src/main/webapp/WEB-INF/faces-config.xml index 0b31b305..5ea0a83d 100644 --- a/spring-webflow-samples/sellitem-jsf/src/main/webapp/WEB-INF/faces-config.xml +++ b/spring-webflow-samples/sellitem-jsf/src/main/webapp/WEB-INF/faces-config.xml @@ -26,7 +26,7 @@ - + org.springframework.web.jsf.DelegatingPhaseListenerMulticaster diff --git a/spring-webflow-samples/sellitem-jsf/src/main/webapp/error.jsp b/spring-webflow-samples/sellitem-jsf/src/main/webapp/error.jsp deleted file mode 100644 index 65d8ab8c..00000000 --- a/spring-webflow-samples/sellitem-jsf/src/main/webapp/error.jsp +++ /dev/null @@ -1,17 +0,0 @@ -<%@ include file="includeTop.jsp" %> - -
-
- -
-

- - Duplicate submit of the same transaction not allowed! - -

-

- Sell a new item -

-
- -<%@ include file="includeBottom.jsp" %> \ No newline at end of file