0

I have Spring 3 application having Tiles2 as view resolver. Whenever I am clicking on "submit" button next jsp page should be displayed but it stays on same page.

I have a file WebFlow.xml file inside /WEB-INF/flow directory and JSPs are also in same folder.

My configuration as follows: -servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    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-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
<mvc:annotation-driven/>
    <context:component-scan base-package="com.controller.*"/>

    <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.tiles2.TilesViewResolver"/>

    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles.xml</value>
            </list>
        </property>
    </bean>
<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>

    <flow:flow-registry id="flowRegistry">
        <flow:flow-location path="/WEB-INF/flow/WebFlow.xml" id="flow"/>
    </flow:flow-registry>

    <bean id="flowHandlerMapping" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry"/>
    </bean>

    <bean id="flowHandlerAdapter" class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor"/>
    </bean>
</beans>

WebFlow.xml

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

    <var name="studentRegForm" class="com.formbean.flows.StudRegForm"/>

    <view-state id="login" view="login">
        <transition on="studentReg" to="studentReg"/>
    </view-state>

    <view-state id="studentReg" view="studentReg" model="studentRegForm">
        <transition on="submitStudInfo" to="studConfirmPage"/>
    </view-state>

    <view-state id="studConfirmPage">
        <transition on="submit" to="showStoredPage"/>
        <transition on="Cancel" to="studentReg"/>
    </view-state>

    <end-state id="showStoredPage"/>
</flow>

login.jsp

<sf:form id="loginFrm" modelAttribute="loginForm" method="GET" action="${flowExecutionUrl}">
        <input type="text" name="_flowExecutionKey" value="${flowExecutionKey}"/>
        <input type="submit" value="Student Registration" name="_eventId_studentReg"/>
    </sf:form>

StudentReg.jsp

<sf:form id="studRegFrm" modelAttribute="studentRegForm" method="GET" action="${flowExecutionUrl}">
    <input type="text" name="_flowExecutionKey" value="${flowExecutionKey}"/>
        <table>
            <tr>
                <td><sf:label path="name">Please Enter Name:</sf:label></td>
                <td><sf:input path="name"/></td>
            </tr>
            <tr>
                <td><sf:label path="address">Please Enter Address:</sf:label></td>
                <td><sf:input path="address"/></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" name="_eventId_submitStudInfo" value="Submit"/></td>
            </tr>
        </table>
    </sf:form>

tiles.xml

<tiles-definitions>
    <definition name="mainLayout" template="/WEB-INF/jsp/layout/mainLayout.jsp">
        <put-attribute name="Title" value=""/>
        <put-attribute name="Header" value="/WEB-INF/jsp/layout/Header.jsp"/>
        <put-attribute name="Body" value=""/>
        <put-attribute name="Footer" value="/WEB-INF/jsp/layout/Footer.jsp"/>
    </definition>

    <definition name="login" extends="mainLayout">
        <put-attribute name="Title" value="Start Page"></put-attribute>
        <put-attribute name="Body" value="/WEB-INF/flow/login.jsp"/>
    </definition>

    <definition name="studentReg" extends="mainLayout">
        <put-attribute name="Title" value="Registration Page"></put-attribute>
        <put-attribute name="Body" value="/WEB-INF/flow/StudentReg.jsp"/>
    </definition>
</tiles-definitions>

But whenever I am clicking on submit button of login.jsp, it gives ${flowExecutionUrl} & ${flowExecutionKey} as blank and next screen is not displaying. Am I missing some configuration or what's going wrong? Please help.

Aasif Solkar
  • 81
  • 1
  • 12

1 Answers1

0

@Aasif your configuration 'looks' fine. SWF is notoriously un-intuitive to trouble shoot. Try inserting a logger into your flows like this:

Printing log from flow.xml

and determine where the the 'flow' execution is being interrupted. Once you isolate the location. Try to step into the flow code... I suspect an exception is being swallowed.

Possible Answer:

If I had to guess (even though your config looks correct). I would suspect SWF/tiles is NOT resolving the view name 'studentReg'. Try isolate this case by creating a separate flow and see if you can navigate to the view studentReg. You can also step into the Tiles resolver logic to make sure it is being located.

Also:

In my opinion, it is bad practice to give the same name to your viewStateId, transition, and viewName (i.e 'studentReg'). I think it makes trouble shooting more difficult when issues like this arise. Better to append a suffix to them. (i.e studentRegVsId, studentRegViewName, etc...) to create a distinction.

Community
  • 1
  • 1
Selwyn
  • 3,118
  • 1
  • 26
  • 33
  • Thanks for help. Actually I got soultion for it as: 1] Added flow-builder-services and mvcViewFactoryCreator. Also I have started flow by adding flow ID in index.jsp page as I am redirecting from it to login page. – Aasif Solkar Feb 19 '16 at 05:51