Moved Spring Web Flow to a top level project
This commit is contained in:
33
spring-webflow-samples/birthdate/src/etc/filter.properties
Normal file
33
spring-webflow-samples/birthdate/src/etc/filter.properties
Normal file
@@ -0,0 +1,33 @@
|
||||
# $Header$
|
||||
|
||||
# Contains filterable project settings. Setting placeholders in filterable project text
|
||||
# files will be replaced with these values when the 'statics' build target is run.
|
||||
#
|
||||
# You may add static settings directly to this source file in the format:
|
||||
# setting=value e.g MY_SETTING=myvalue
|
||||
# This is appropriate usage if you know the setting value will never change.
|
||||
#
|
||||
# At build time this source file is copied to the ${target.dir} where additional
|
||||
# dynamic settings may be appended using the <propertyfile> task. Use this approach
|
||||
# when a setting value depends on the build or the local user's environment.
|
||||
#
|
||||
# An example of this approach is shown below:
|
||||
#
|
||||
# build.xml
|
||||
# <target name="build.prepare" depends="common-targets.build.prepare">
|
||||
# <!-- Append additional local settings that are applicable to this project -->
|
||||
# <propertyfile file="${target.filter.file}">
|
||||
# <!-- key=the name of the setting
|
||||
# value=the property in your build.properties file that has the local setting value -->
|
||||
# <entry key="MY_LOCAL_SETTING" value="${my.local.setting}" />
|
||||
# </propertyfile>
|
||||
# </target>
|
||||
#
|
||||
# This allows for dynamic replacement values that are sourced from local properties files to facilitate
|
||||
# local user settings.
|
||||
#
|
||||
# To refer to filterable settings within project source files like config files, JSPs, or
|
||||
# other text files use the standard ant placeholder format:
|
||||
# @SETTING_NAME@ e.g, @MY_SETTING@ and @MY_LOCAL_SETTING@
|
||||
#
|
||||
# Your settings:
|
||||
@@ -0,0 +1,15 @@
|
||||
log4j.rootCategory=DEBUG, stdout, logfile
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.logfile.File=@TEST_RESULTS_DIR@/@PROJECT_NAME@.log
|
||||
log4j.appender.logfile.MaxFileSize=512KB
|
||||
|
||||
# Keep three backup files
|
||||
log4j.appender.logfile.MaxBackupIndex=3
|
||||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
||||
#Pattern to output : date priority [category] - <message>line_separator
|
||||
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.webflow.samples.birthdate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class BirthDate implements Serializable {
|
||||
|
||||
private String name;
|
||||
|
||||
private Date date;
|
||||
|
||||
private boolean sendCard;
|
||||
|
||||
private String emailAddress;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public boolean isSendCard() {
|
||||
return sendCard;
|
||||
}
|
||||
|
||||
public void setSendCard(boolean sendCard) {
|
||||
this.sendCard = sendCard;
|
||||
}
|
||||
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmailAddress(String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.webflow.samples.birthdate;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.springframework.beans.PropertyEditorRegistry;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.webflow.action.FormAction;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.ScopeType;
|
||||
|
||||
public class BirthDateFormAction extends FormAction {
|
||||
|
||||
// standard European format
|
||||
private static final String BIRTH_DATE_PATTERN = "dd-MM-yyyy";
|
||||
|
||||
private static final String AGE_NAME = "age";
|
||||
|
||||
public BirthDateFormAction() {
|
||||
// tell the superclass about the form object and validator we want to use
|
||||
// you could also do this in the application context XML ofcourse
|
||||
setFormObjectName("birthDate");
|
||||
setFormObjectClass(BirthDate.class);
|
||||
setFormObjectScope(ScopeType.FLOW);
|
||||
setValidator(new BirthDateValidator());
|
||||
}
|
||||
|
||||
protected void registerPropertyEditors(PropertyEditorRegistry registry) {
|
||||
// register a custom property editor to handle the date input
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(BIRTH_DATE_PATTERN);
|
||||
registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
|
||||
}
|
||||
|
||||
/*
|
||||
* Our "onSubmit" hook: an action execute method.
|
||||
*/
|
||||
public Event calculateAge(RequestContext context) throws Exception {
|
||||
// pull the date from the model
|
||||
BirthDate birthDate = (BirthDate)getFormObject(context);
|
||||
|
||||
// calculate the age (quick & dirty)
|
||||
// in a real application you would delegate to the business layer for
|
||||
// this kind of logic
|
||||
Calendar calBirthDate = new GregorianCalendar();
|
||||
calBirthDate.setTime(birthDate.getDate());
|
||||
Calendar calNow = new GregorianCalendar();
|
||||
|
||||
int ageYears = calNow.get(Calendar.YEAR) - calBirthDate.get(Calendar.YEAR);
|
||||
long ageMonths = calNow.get(Calendar.MONTH) - calBirthDate.get(Calendar.MONTH);
|
||||
long ageDays = calNow.get(Calendar.DAY_OF_MONTH) - calBirthDate.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
if (ageDays < 0) {
|
||||
ageMonths--;
|
||||
ageDays += calBirthDate.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
if (ageMonths < 0) {
|
||||
ageYears--;
|
||||
ageMonths += 12;
|
||||
}
|
||||
|
||||
// create a nice age string
|
||||
StringBuffer ageStr = new StringBuffer();
|
||||
ageStr.append(ageYears).append(" years, ");
|
||||
ageStr.append(ageMonths).append(" months and ");
|
||||
ageStr.append(ageDays).append(" days");
|
||||
|
||||
// put it in the model for display by the view
|
||||
context.getRequestScope().put(AGE_NAME, ageStr);
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.webflow.samples.birthdate;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
public class BirthDateValidator implements Validator {
|
||||
|
||||
public boolean supports(Class clazz) {
|
||||
return clazz.equals(BirthDate.class);
|
||||
}
|
||||
|
||||
public void validate(Object obj, Errors errors) {
|
||||
BirthDate birthDate = (BirthDate)obj;
|
||||
validateBirthdateForm(birthDate, errors);
|
||||
validateCardForm(birthDate, errors);
|
||||
}
|
||||
|
||||
public void validateBirthdateForm(BirthDate birthDate, Errors errors) {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "noName", "Please specify your name.");
|
||||
ValidationUtils.rejectIfEmpty(errors, "date", "noDate", "Please specify your birth date.");
|
||||
}
|
||||
|
||||
public void validateCardForm(BirthDate birthDate, Errors errors) {
|
||||
if (birthDate.isSendCard()) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(birthDate.getDate());
|
||||
if (cal.get(Calendar.MONTH) == 11) {
|
||||
errors.reject("tooGoodForCards", "You're born in December--you're too good for a silly card!");
|
||||
}
|
||||
else {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "noEmail",
|
||||
"Please specify your email address.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
errors.header=<table>
|
||||
errors.footer=</table>
|
||||
errors.prefix=<tr><td><font color="red">
|
||||
errors.suffix=</font></td></tr>
|
||||
|
||||
noName=Your name is required
|
||||
noDate=Your birth date is required
|
||||
noEmail=Your email address is required
|
||||
typeMismatch.java.util.Date=You entered an invalid date format
|
||||
|
||||
tooGoodForCards=You're born in December--you're too good for a silly card!
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
This simple flow demonstrates the use of the FormAction: a multi-action.
|
||||
Notice how all the actions use the same "formAction" bean, which groups
|
||||
all actions executed by this flow in single class.
|
||||
|
||||
This is a simplified alternate definition of the BirthDate flow (see birthdate.xml) that
|
||||
uses view state render actions and transition actions to make the flow definition more compact.
|
||||
-->
|
||||
<flow xmlns="http://www.springframework.org/schema/webflow"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
|
||||
|
||||
<start-state idref="enterBirthdate" />
|
||||
|
||||
<view-state id="enterBirthdate" view="birthdateForm">
|
||||
<render-actions>
|
||||
<action bean="formAction" method="setupForm" />
|
||||
</render-actions>
|
||||
<transition on="submit" to="enterCardInformation">
|
||||
<action bean="formAction" method="bindAndValidate">
|
||||
<attribute name="validatorMethod" value="validateBirthdateForm" />
|
||||
</action>
|
||||
</transition>
|
||||
</view-state>
|
||||
|
||||
<view-state id="enterCardInformation" view="cardForm">
|
||||
<transition on="submit" to="calculateAge">
|
||||
<action bean="formAction" method="bindAndValidate">
|
||||
<attribute name="validatorMethod" value="validateCardForm" />
|
||||
</action>
|
||||
</transition>
|
||||
</view-state>
|
||||
|
||||
<action-state id="calculateAge">
|
||||
<action bean="formAction" method="calculateAge" />
|
||||
<transition on="success" to="displayAge" />
|
||||
</action-state>
|
||||
|
||||
<end-state id="displayAge" view="yourAge" />
|
||||
|
||||
</flow>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow xmlns="http://www.springframework.org/schema/webflow"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
|
||||
|
||||
<start-state idref="enterBirthdate" />
|
||||
|
||||
<!-- Display the first input form view -->
|
||||
<view-state id="enterBirthdate" view="birthdateForm">
|
||||
<!--
|
||||
Prepare to display a new form. Initializes the backing "form object" and installs property
|
||||
editors to format form field values.
|
||||
-->
|
||||
<render-actions>
|
||||
<action bean="formAction" method="setupForm" />
|
||||
</render-actions>
|
||||
<transition on="submit" to="processBirthdateFormSubmit" />
|
||||
</view-state>
|
||||
|
||||
<!-- Bind and validate input data from the form -->
|
||||
<action-state id="processBirthdateFormSubmit">
|
||||
<action bean="formAction" method="bindAndValidate">
|
||||
<attribute name="validatorMethod" value="validateBirthdateForm" />
|
||||
</action>
|
||||
<transition on="success" to="enterCardInformation" />
|
||||
<transition on="error" to="enterBirthdate" />
|
||||
</action-state>
|
||||
|
||||
<!-- Display the next input form view -->
|
||||
<view-state id="enterCardInformation" view="cardForm">
|
||||
<transition on="submit" to="processCardFormSubmit" />
|
||||
</view-state>
|
||||
|
||||
<!-- Bind and validate input data from the form -->
|
||||
<action-state id="processCardFormSubmit">
|
||||
<action bean="formAction" method="bindAndValidate">
|
||||
<attribute name="validatorMethod" value="validateCardForm" />
|
||||
</action>
|
||||
<transition on="success" to="calculateAge" />
|
||||
<transition on="error" to="enterCardInformation" />
|
||||
</action-state>
|
||||
|
||||
<!-- Process the transaction -->
|
||||
<action-state id="calculateAge">
|
||||
<action bean="formAction" method="calculateAge" />
|
||||
<transition on="success" to="displayAge" />
|
||||
</action-state>
|
||||
|
||||
<!-- Display the success view. -->
|
||||
<end-state id="displayAge" view="yourAge" />
|
||||
|
||||
</flow>
|
||||
@@ -0,0 +1,9 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
# Enable web flow logging
|
||||
log4j.category.org.springframework.webflow=DEBUG
|
||||
log4j.category.org.springframework.binding=DEBUG
|
||||
@@ -0,0 +1,36 @@
|
||||
<%@ include file="includeTop.jsp" %>
|
||||
|
||||
<div id="content">
|
||||
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
|
||||
<h2>Enter your birth date</h2>
|
||||
<hr>
|
||||
<html:form action="flowAction" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<html:errors/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Your name</td>
|
||||
<td>
|
||||
<html:text property="name" size="25" maxlength="30"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Your birth date (DD-MM-YYYY)</td>
|
||||
<td>
|
||||
<html:text property="date" size="10" maxlength="10"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="buttonBar">
|
||||
<html:image src="images/submit.gif" property="_eventId_submit" value="Next"/>
|
||||
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
|
||||
</td>
|
||||
</tr>
|
||||
</html:form>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%@ include file="includeBottom.jsp" %>
|
||||
@@ -0,0 +1,39 @@
|
||||
<%@ include file="includeTop.jsp" %>
|
||||
|
||||
<div id="content">
|
||||
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
|
||||
<h2>Personalized birthday cards</h2>
|
||||
<hr>
|
||||
<html:form action="flowAction" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<html:errors/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Would you like a card to be sent on your birthday?</td>
|
||||
<td>
|
||||
<html:checkbox property="sendCard"/>
|
||||
<!-- Checkboxes don't send anything when not selected, so this marker is used to detect
|
||||
a false submission -->
|
||||
<input type="hidden" name="_sendCard" value="marker"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>If so, enter your email address:</td>
|
||||
<td>
|
||||
<html:text property="emailAddress" size="25" maxlength="128"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="buttonBar">
|
||||
<html:image src="images/submit.gif" property="_eventId_submit" value="Calculate Age"/>
|
||||
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
|
||||
</td>
|
||||
</tr>
|
||||
</html:form>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%@ include file="includeBottom.jsp" %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<div id="copyright">
|
||||
<p>© Copyright 2002-2006, <a href="http://www.springframework.org">www.springframework.org</a>, under the terms of the Apache 2.0 software license.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<%@ page contentType="text/html" %>
|
||||
<%@ page session="false" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Calculate your Age</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="logo">
|
||||
<img src="images/spring-logo.jpg" alt="Logo">
|
||||
</div>
|
||||
|
||||
<div id="navigation">
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
<%@ include file="includeTop.jsp" %>
|
||||
|
||||
<div id="content">
|
||||
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
|
||||
<h2>Your age</h2>
|
||||
<hr>
|
||||
<p>
|
||||
${birthDate.name}, you are now <I>${age}</I> old.
|
||||
You were born on <fmt:formatDate value="${birthDate.date}" pattern="dd-MM-yyyy"/>.
|
||||
</p>
|
||||
<hr>
|
||||
<form action="<c:url value="/index.jsp"/>">
|
||||
<INPUT type="submit" value="Home">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<%@ include file="includeBottom.jsp" %>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!DOCTYPE struts-config PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
|
||||
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
|
||||
|
||||
<struts-config>
|
||||
|
||||
<form-beans>
|
||||
<!-- A single ActionForm adapter for your entire app is all you need, if you
|
||||
wish to take advantage of Spring's POJO-based data binding and validation. -->
|
||||
<form-bean name="actionForm" type="org.springframework.web.struts.SpringBindingActionForm"/>
|
||||
</form-beans>
|
||||
|
||||
<global-forwards>
|
||||
<forward name="birthdateForm" path="/WEB-INF/jsp/birthdateForm.jsp"/>
|
||||
<forward name="cardForm" path="/WEB-INF/jsp/cardForm.jsp"/>
|
||||
<forward name="yourAge" path="/WEB-INF/jsp/yourAge.jsp"/>
|
||||
</global-forwards>
|
||||
|
||||
<action-mappings>
|
||||
<action path="/home" forward="index.jsp"/>
|
||||
<action path="/flowAction" name="actionForm" scope="request" type="org.springframework.webflow.executor.struts.FlowAction"/>
|
||||
</action-mappings>
|
||||
|
||||
<message-resources parameter="org.springframework.webflow.samples.birthdate.MessageResources"/>
|
||||
|
||||
</struts-config>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
/WEB-INF/webflow-config.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>action</servlet-name>
|
||||
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>action</servlet-name>
|
||||
<url-pattern>*.do</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:flow="http://www.springframework.org/schema/webflow-config"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/webflow-config
|
||||
http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd">
|
||||
|
||||
<!-- Launches new flow executions and resumes existing executions. -->
|
||||
<flow:executor id="flowExecutor" registry-ref="flowRegistry"/>
|
||||
|
||||
<!-- Creates the registry of flow definitions for this application -->
|
||||
<flow:registry id="flowRegistry">
|
||||
<flow:location path="/WEB-INF/birthdate.xml"/>
|
||||
<flow:location path="/WEB-INF/birthdate-alternate.xml"/>
|
||||
</flow:registry>
|
||||
|
||||
<!-- Manages the birthdate wizard's "form backing object" -->
|
||||
<bean id="formAction" class="org.springframework.webflow.samples.birthdate.BirthDateFormAction" />
|
||||
|
||||
</beans>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
36
spring-webflow-samples/birthdate/src/main/webapp/index.jsp
Normal file
36
spring-webflow-samples/birthdate/src/main/webapp/index.jsp
Normal file
@@ -0,0 +1,36 @@
|
||||
<%-- make sure we have a session --%>
|
||||
<%@ page session="true" %>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
<DIV align="left">Birth Date - A Spring Web Flow Sample</DIV>
|
||||
|
||||
<HR>
|
||||
|
||||
<DIV align="left">
|
||||
<P>
|
||||
<A href="flowAction.do?_flowId=birthdate">Birth Date</A>
|
||||
</P>
|
||||
|
||||
<P>
|
||||
This sample application demonstrates the use of the FormAction: a multi-action.
|
||||
It also shows you how to use a multi-action to group all actions executed by a flow
|
||||
in a single class.
|
||||
</P>
|
||||
<P>
|
||||
This sample also demonstrates Spring Web Flow's Struts integration.</P>
|
||||
<P>
|
||||
Finally, the sample also uses JSTL in conjunction with flows.
|
||||
</P>
|
||||
</DIV>
|
||||
|
||||
<HR>
|
||||
|
||||
<DIV align="right"></DIV>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
58
spring-webflow-samples/birthdate/src/main/webapp/style.css
Normal file
58
spring-webflow-samples/birthdate/src/main/webapp/style.css
Normal file
@@ -0,0 +1,58 @@
|
||||
body {
|
||||
width: 720px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
div#logo {
|
||||
width: 720px;
|
||||
height: 73px;
|
||||
background: #86AEA5;
|
||||
}
|
||||
|
||||
div#navigation {
|
||||
width: 720px;
|
||||
height: 15px;
|
||||
background: #E2F3B8;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div#content {
|
||||
width: 720px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
div#insert {
|
||||
width: 120;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.buttonBar {
|
||||
height: 1.5em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div#copyright {
|
||||
width: 720px;
|
||||
}
|
||||
|
||||
div#copyright p {
|
||||
text-align: center;
|
||||
font-family: Tahoma, sans-serif;
|
||||
font-size: 75%;
|
||||
color: div#336633;
|
||||
margin-left: 5px;
|
||||
font-weight: bold;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.readOnly {
|
||||
color: rgb(192, 192, 192);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
# Enable web flow logging
|
||||
log4j.category.org.springframework.webflow=DEBUG
|
||||
log4j.category.org.springframework.binding=DEBUG
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.webflow.samples.birthdate;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.validation.BindException;
|
||||
|
||||
public class BirthdateValidatorTests extends TestCase {
|
||||
|
||||
public void testValidateCardForm() throws Exception {
|
||||
BirthDateValidator validator = new BirthDateValidator();
|
||||
BirthDate birthDate = new BirthDate();
|
||||
birthDate.setName("Keith");
|
||||
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
|
||||
birthDate.setSendCard(true);
|
||||
birthDate.setDate(format.parse("29/12/1977"));
|
||||
BindException errors = new BindException(birthDate, "birthDate");
|
||||
validator.validateCardForm(birthDate, errors);
|
||||
assertEquals(1, errors.getAllErrors().size());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user