Cleanup of the sellitem-jsf sample application.

This commit is contained in:
Erwin Vervaet
2007-02-17 21:10:50 +00:00
parent 727ea5295a
commit 48805699eb
5 changed files with 9 additions and 26 deletions

View File

@@ -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);
}

View File

@@ -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 (?, ?, ?, ?, ?)",

View File

@@ -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");
}

View File

@@ -26,7 +26,7 @@
</application>
<lifecycle>
<!-- Multi-caster that broadcast phase events to all PhaseListeners managed by Spring -->
<!-- Multi-caster that broadcasts phase events to all PhaseListeners managed by Spring -->
<phase-listener>org.springframework.web.jsf.DelegatingPhaseListenerMulticaster</phase-listener>
</lifecycle>

View File

@@ -1,17 +0,0 @@
<%@ include file="includeTop.jsp" %>
<div id="content">
<div id="insert">
<img src="images/webflow-logo.jpg"/>
</div>
<p>
<span class="error">
Duplicate submit of the same transaction not allowed!
</span>
</p>
<p>
<A href="pos.htm?_flowId=sellitem">Sell a new item</A>
</p>
</div>
<%@ include file="includeBottom.jsp" %>