<?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-2.0.xsd"
	start-state="findExistingPlayerForm">

	<view-state id="findExistingPlayerForm">
		<on-render>
			<!-- Prepares the form object for display on a form -->
			<evaluate expression="findExistingPlayerFormAction.setupForm" />
		</on-render>
		<transition on="find" to="findExistingPlayerActionState">
			<!-- Binds all incoming request parameters to the form object and then 
				validates the form object using a registered validator. This action method 
				will return the "success" event if there are no binding or validation errors, 
				otherwise it will return the "error" event. -->
			<evaluate expression="findExistingPlayerFormAction.bindAndValidate" />
		</transition>
	</view-state>

	<action-state id="findExistingPlayerActionState">
		<!--Each of the following achieves the same functionality. -->

		<!-- Using FindExistingPlayerAction.java... <evaluate expression="findExistingPlayerAction" 
			/> -->

		<!-- Or using PlayerActions.java - Syntax #1 -->
		<evaluate expression="playerActions.findExistingPlayer" />

		<!-- Or using PlayerActions.java - Syntax #2 By convention, the "id" of 
			the wrapping action-state will be treated as the method to execute. If our 
			state id was "findExistingPlayer" instead of "findExistingPlayerActionState", 
			we could have just used the following: <evaluate expression="playerActions" 
			/> -->

		<transition on="success" to="displayFindExistingPlayerResult" />
	</action-state>

	<!-- You can either end the subflow or reset the form and start over... -->
	<!--action-state id="newSearch"> <evaluate expression="findExistingPlayerFormAction.resetForm"/> 
		<transition on="success" to="findExistingPlayerForm"/> </action-state -->

	<view-state id="displayFindExistingPlayerResult">
		<transition on="back" to="findExistingPlayerForm" />
		<transition on="newSearch" to="newSearchEndState" />
		<transition on="noneMatch" to="endState" />
		<transition on="existingAccountFound" to="existingAccountFoundEndState" />
	</view-state>

	<end-state id="newSearchEndState" />

	<end-state id="endState" />

	<end-state id="existingAccountFoundEndState">
		<output name="loginUsername" value="player.guardian.username" />
	</end-state>

	<global-transitions>
		<transition on="skip" to="endState" />
	</global-transitions>
</flow>