Moved Spring Web Flow to a top level project

This commit is contained in:
Ben Hale
2006-12-21 16:02:27 +00:00
commit e7ecbbc7e5
1083 changed files with 80775 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1,36 @@
<?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">
<!--
Exposes web flows for execution at a single request URL.
The id of a flow to launch should be passed in by clients using
the "_flowId" request parameter:
e.g. /play.htm?_flowId=mastermind
-->
<bean name="/play.htm" class="org.springframework.webflow.executor.mvc.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<!-- Launches new flow executions and resumes existing executions. -->
<flow:executor id="flowExecutor" registry-ref="flowRegistry" repository-type="singlekey"/>
<!-- Creates the registry of flow definitions for this application -->
<flow:registry id="flowRegistry">
<flow:location path="/WEB-INF/higherlower.xml" />
<flow:location path="/WEB-INF/mastermind.xml" />
</flow:registry>
<!-- Resolves flow view names to .jsp templates -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>

View File

@@ -0,0 +1,26 @@
<?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">
<var name="game" class="org.springframework.webflow.samples.numberguess.HigherLowerGame"/>
<start-state idref="enterGuess"/>
<view-state id="enterGuess" view="higherlower.enterGuess">
<transition on="submit" to="makeGuess"/>
</view-state>
<action-state id="makeGuess">
<evaluate-action expression="flowScope.game.makeGuess(requestParameters.guess)">
<evaluation-result name="guessResult"/>
</evaluate-action>
<transition on="CORRECT" to="showAnswer"/>
<transition on="*" to="enterGuess"/>
<transition on-exception="java.lang.NumberFormatException" to="enterGuess"/>
</action-state>
<end-state id="showAnswer" view="higherlower.showAnswer"/>
</flow>

View File

@@ -0,0 +1,34 @@
<%@ include file="includeTop.jsp" %>
<div id="content">
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
<h2>The Number Guess Game</h2>
<h3>Guess a number between 0 and 100!</h3>
<hr>
<form name="guessForm" method="post">
<table>
<tr class="readOnly">
<td>Number of guesses:</td>
<td><b>${game.guesses}</b></td>
</tr>
<tr class="readOnly">
<td>Your last guess was:</td>
<td><b><i>${game.result}</i></b></td>
</tr>
<tr>
<td>Guess:</td>
<td>
<input type="text" name="guess" value="${param.guess}">
</td>
</tr>
<tr>
<td colspan="2" class="buttonBar">
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<input type="submit" class="button" name="_eventId_submit" value="Guess">
</td>
</tr>
</table>
</form>
</div>
<%@ include file="includeBottom.jsp" %>

View File

@@ -0,0 +1,29 @@
<%@ include file="includeTop.jsp" %>
<div id="content">
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
<h2>You guessed it!</h2>
<table>
<tr>
<td>Answer:</td>
<td>${game.answer}</td>
</tr>
<tr>
<td>Total number of guesses:</td>
<td>${game.guesses}</td>
</tr>
<tr>
<td>Elapsed time in seconds:</td>
<td>${game.duration}</td>
</tr>
<tr>
<td colspan="2" class="buttonBar">
<form action="play.htm">
<input type="hidden" name="_flowId" value="higherlower">
<input type="submit" value="Play Again!">
</form>
</td>
</tr>
</table>
<%@ include file="includeBottom.jsp" %>

View File

@@ -0,0 +1,5 @@
<div id="copyright">
<p>&copy; 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>

View File

@@ -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 prefix="spring" uri="http://www.springframework.org/tags" %>
<html>
<head>
<title>Play a game</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>

View File

@@ -0,0 +1,34 @@
<%@ include file="includeTop.jsp" %>
<div id="content">
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
<h2>Mastermind</h2>
<h3>Guess a four digit number!</h3>
<hr>
<p>Note: each guess must be 4 unique digits!</p>
<p>Number of guesses so far: ${game.data.guesses}</p>
<%@include file="mastermind.guessHistoryTable.jsp" %>
<form name="guessForm" method="post">
<c:if test="${game.result == 'INVALID'}">
<div class="error">Your guess was invalid: it must be a 4 digit number (e.g 1234), and each digit must be unique.</div>
</c:if>
<table>
<tr>
<td>Guess:</td>
<td align="left">
<input type="text" name="guess" value="${param.guess}">
</td>
</tr>
<tr>
<td colspan="2" class="buttonBar">
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<input type="submit" class="button" name="_eventId_submit" value="Guess">
</td>
</tr>
</table>
</form>
</div>
<%@ include file="includeBottom.jsp" %>

View File

@@ -0,0 +1,15 @@
<c:if test="${!empty game.guessHistory}">
<h4>Guess history:</h4>
<table border="1">
<th>Guess</th>
<th>Right Position</th>
<th>Present But Wrong Position</th>
<c:forEach var="guessData" items="${game.guessHistory}">
<tr>
<td>${guessData.guess}</td>
<td>${guessData.rightPosition}</td>
<td>${guessData.correctButWrongPosition}</td>
</tr>
</c:forEach>
</table>
</c:if>

View File

@@ -0,0 +1,28 @@
<%@ include file="includeTop.jsp" %>
<div id="content">
<div id="insert"><img src="images/webflow-logo.jpg"/></div>
<h2>Show answer</h2>
<table>
<tr>
<td>Total number of guesses:</td>
<td>${game.data.guesses}</td>
</tr>
<tr>
<td>Elapsed time in seconds:</td>
<td>${game.data.duration}</td>
</tr>
<tr>
<td>Answer:</td>
<td>${game.data.answer}</td>
</tr>
<tr>
<td colspan="2" class="buttonBar">
<form action="play.htm">
<input type="hidden" name="_flowId" value="mastermind">
<input type="submit" value="Play Again!">
</form>
</td>
</tr>
</table>
<%@ include file="includeBottom.jsp" %>

View File

@@ -0,0 +1,25 @@
<?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">
<var name="game" class="org.springframework.webflow.samples.numberguess.MastermindGame"/>
<start-state idref="enterGuess"/>
<view-state id="enterGuess" view="mastermind.enterGuess">
<transition on="submit" to="makeGuess"/>
</view-state>
<action-state id="makeGuess">
<evaluate-action expression="flowScope.game.makeGuess(requestParameters.guess)">
<evaluation-result name="guessResult"/>
</evaluate-action>
<transition on="CORRECT" to="showAnswer"/>
<transition on="*" to="enterGuess"/>
</action-state>
<end-state id="showAnswer" view="mastermind.showAnswer"/>
</flow>

View File

@@ -0,0 +1,22 @@
<?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">
<servlet>
<servlet-name>numberguess</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>numberguess</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,40 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV align="left">Number Guess - A Spring Web Flow Sample</DIV>
<HR>
This Spring Web Flow (SWF) sample application illustrates:
<ul>
<li>
Use of stateful middle-tier components to carry out the execution of game business logic. It shows how to use SWF to
develop such components without coupling your application code to SWF APIs.
</li>
<li>
Use of custom state exception handlers to handle exceptions.
</li>
<li>
Use of the evaluate-action to evaluate expressions against the flow request context;
in this example to call the "makeGuess" method on a flow-scoped "game" bean.
</li>
</ul>
<DIV align="left">
<P>
<A href="play.htm?_flowId=higherlower">Play Higher or Lower</A>
</P>
<p>
The well known higher-or-lower number guess sample app.
</p>
</DIV>
<DIV align="left">
<P>
<A href="play.htm?_flowId=mastermind">Play Mastermind</A>
</P>
<P>
Figure out the 4 digit number - a fun mindteaser sample app.
</P>
</DIV>
<HR>
</BODY>
</HTML>

View 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;
}