I am using Spring Web Flow to a registration process. I have the first page of the flow perfectly, but when I click on the button that should take you to page two, I get again the first page of the flow. As you will see in the code, I have flowExecutionKey on a label, and it goes from e1s1 to e2s1 when I click on the button, so instead of leading me to the second view of the flow, it starts a new flow, I think.
Here is the code:
So, I have this flow.xml:
<?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="inicio">
<var name="proyecto" class="myPackage.MyModelClass"/>
<view-state id="inicio" view="inicio" model="proyecto">
<binder>
<binding property="titulo"/>
<binding property="descripcion"/>
<binding property="ciudad"/>
</binder>
<transition on="gotoPageTwo" to="flow2"></transition>
</view-state>
<view-state id="flow2" view="flow2" model="proyecto">
<transition on="gotoPageThree" to="flow3"></transition>
<transition on="goBack" to="inicio"></transition>
</view-state>
<view-state id="flow3" view="flow3" model="proyecto">
<transition on="gotoPageFour" to="fin"></transition>
<transition on="goBack" to="flow2"></transition>
</view-state>
<end-state id="fin" view="final">
</end-state>
This is my inicio.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="/myapp/resources/css/main.css" rel="stylesheet" type="text/css">
<link href="/myapp/resources/css/tcal.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/myapp/resources/scripts/tcal.js"></script>
<title>Paso 1</title>
</head>
<body>
<form method="post" action="inicio.do">
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
<label>flowExecutionKey: ${flowExecutionKey}</label>
<table>
<tr>
<td>
<label class="textform">Título del proyecto</label>
</td>
<td>
<input type="text" name="titulo">
</td>
</tr>
<tr>
<td>
<label class="textform">Descripción</label>
</td>
<td>
<input type="text" name="descripcion">
</td>
</tr>
<tr>
<td>
<label class="textform">Ciudad del proyecto</label>
</td>
<td>
<input type="text" name="ciudad">
</td>
</tr>
<tr>
<td>
<input type="submit" value="Siguiente" name="_eventId=gotoPageTwo">
<%--<a href="${flowExecutionUrl}&_eventId=gotoPageTwo&_flowExecutionKey=${flowExecutionKey}"> Siguiente página</a>
<input type="submit" value="Siguiente" name="eventId=gotoPageTwo">
<input type="submit" value="Siguiente" name="${flowExecutionUrl}&_eventId=gotoPageTwo">--%>
</td>
</tr>
As you can see, i try to send an eventId of gotoPageTwo, as is stated in flow.xml.
And Spring web Flow related beans on servlet-context.xml:
<beans:bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<beans:property name="mappings">
<beans:value>inicio.do=flowController</beans:value>
</beans:property>
<beans:property name="alwaysUseFullPath" value="true"></beans:property>
</beans:bean>
<beans:bean id="flowcontroller" class="org.springframework.webflow.mvc.servlet.FlowController">
<beans:property name="flowExecutor" ref="flowExecutor"></beans:property>
</beans:bean>
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location id="inicio" path="/WEB-INF/flujos/flow.xml"/>
</webflow:flow-registry>
<webflow:flow-builder-services id="flowBuilderServices"
view-factory-creator="viewFactoryCreator"/>
<beans:bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<beans:property name="viewResolvers">
<beans:list>
<beans:ref bean="viewResolver"/>
</beans:list>
</beans:property>
</beans:bean>
<beans:bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
Why is this happening? Where is my error? The first link in the comments works and presents the second view, but it does not send the form, I think, so I have no data, and its a link, not a button:
<a href="${flowExecutionUrl}&_eventId=gotoPageTwo&_flowExecutionKey=${flowExecutionKey}"> Siguiente página</a>
The other comments are things I tried, and doesn't work.
Thank you!