The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

340010 (5) [Avatar] Offline
I was playing around with Spring web flow example provided in the book. Rather than using FormAction, i was trying to drive the app with MultiAction implementation. It is driving me nuts that i am not able to Do simple asks like putting a form validation etc. Please see the details below and help me out.

This is my findExisting-Player-flow.xml. here i have used a var and model binding.
Now once this view (findExistingPlayerForm) is rendered, my assumption is that it should validate the form and stop the user then and there on the view itself before passing on the control to searchActions.findExistingPlayer

I tried the same thing in the GIT example of the book by adding some annotations on PlyerSearchCriteria and there also the validation does not work. please please please help me out smilie

Flow xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Source project: sip05, branch: 03 (Maven Project) -->

<flow xmlns=""

	[b]<var name="playerSearchForm" class="com.saurabhd.springwebflow.form.PlayerSearchForm"/>
	<view-state id="findExistingPlayerForm" model="playerSearchForm">
		<transition on="find" to="findExistingPlayerFormActionState">

	<action-state id="findExistingPlayerFormActionState">
		<evaluate expression="searchActions.findExistingPlayer"></evaluate>
		<transition on="success" to="displayFindExistingPlayerResult"></transition>

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

	<end-state id="newSearchEndState" />

	<end-state id="endState" />

	<end-state id="existingAccountFoundEndState">
		<output name="loginUsername" value="" />

Multi Action implementation

public class SearchWorkflowActions extends MultiAction{
	private PlayerService playerService;

	 * @param playerService the playerService to set
	public void setPlayerService(PlayerService playerService) {
		this.playerService = playerService;
	public Event findExistingPlayer(RequestContext context){
		PlayerSearchForm form = (PlayerSearchForm) context.getFlowScope().get("playerSearchForm");
		System.out.println("Search form "+form);
		Player findExistingPlayer = playerService.findExistingPlayer(form);
		context.getFlowScope().put("player", findExistingPlayer);
		return success();


My Search form

public class PlayerSearchForm implements Serializable{
private static final long serialVersionUID = 1L;
	private String firstName;
	private String lastName;
	private String homePhone;
	public String getFirstName() {
		return firstName;
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	public String getLastName() {
		return lastName;
	public void setLastName(String lastName) {
		this.lastName = lastName;
	public String getHomePhone() {
		return homePhone;
	public void setHomePhone(String homePhone) {
		this.homePhone = homePhone;
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	public String toString() {
		return "PlayerSearchForm [firstName=" + firstName + ", lastName="
				+ lastName + ",  homePhone="
				+ homePhone + "]";


Flow spring configuration

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
	xmlns:xsi="" xmlns:flow=""

	<flow:flow-builder-services id="flowBuilderServices"
	<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry"></flow:flow-executor>
	<flow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">
		<flow:flow-location-pattern value="*/**/*-flow.xml" />
	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"
		p:flowExecutor-ref="flowExecutor" />

	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"
		p:flowRegistry-ref="flowRegistry" p:order="0" />
		<bean id="searchActions" class="com.saurabhd.springwebflow.action.SearchWorkflowActions">
		<property name="playerService" ref="playerService"></property>

340010 (5) [Avatar] Offline
Is this forum discontinued? Where can we get help from authors? Please advise.
340010 (5) [Avatar] Offline
An update - I have also tried the model binding in the view state. It also fails to invoke the JSR-303 annotation validations on my bean. smilie

What has worked so far is the custom validate${view-state-id} method. See below:

public void validateFindExistingPlayerForm(ValidationContext context){
        MessageContext messages = context.getMessageContext();
            messages.addMessage(new MessageBuilder().error().source("firstName").
                    defaultText("Please enter the value for First Name.").build());


<var name="playerSearchForm" class="com.saurabhd.springwebflow.form.PlayerSearchForm"/>

    <view-state id="findExistingPlayerForm" model="playerSearchForm">
        <transition on="find" to="findExistingPlayerFormActionState">

Please tell me the best way to validate forms in Spring Webflow. Pleas help!

340010 (5) [Avatar] Offline
Hi Willie,

Update - I have got the validation to work for the configuration where i specify model="formName".

Question is on the following snippet:

	<view-state id="findExistingPlayerForm">
	   Prepares the form object for display on a form
	   <evaluate expression="findExistingPlayerFormAction.setupForm"/>	   	   
		<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"/>	  

Here, even if we put the validations on the fields. The validations do not execute on the call of bindAndValidate. Is it a must to pass a validator here in order to perform the validation? Why dont the annotations work?