Cleanup of the sellitem-jsf sample application.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 (?, ?, ?, ?, ?)",
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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" %>
|
||||
Reference in New Issue
Block a user