Johnathan Smith
Johnathan Smith

Reputation: 1112

How do I pass a new model to a view-state in Spring WebFlow2

How do I pass a new model to a view-state in Spring WebFlow2. I have a input screen where my user enters some data and then it goes back to the server to process it. If the data is ok then I have to setup a Ticket Model and pass it to the next view-state to display.

I can't get the next view-state to display the data in the Ticket. Can someone please help me out.

My Flow:

<view-state id="MemberInquiry" view="question.jsp" model="memberrequest" >
        <transition on="submit" to="endState">
            <evaluate expression="flowActions.addInquiry(memberrequest)" result="flowScope.ticket"/>
        </transition>

        <transition on="cancel" to="endState" bind="false"/>
    </view-state>

    <view-state id="endState" view="thanks.jsp" >

    </view-state>

Here is the code in the controller:

public Ticket addInquiry(MemberRequest memberrequest) {

        LOGGER.debug("[" + memberrequest.toString() + "]");

        // Setting data over to RT

        String Ticket = memberInquiryService.sentWebRequest(memberrequest);

        /*
         * Setting out the ticket number to be displayed to user
         */

        Map<String, Object> model = new HashMap<String, Object>();
        Ticket t = new Ticket();
        t.setTicketDetails(Ticket);

        LOGGER.debug("[" + t.toString() + "]");

        return t;
    }

Here is the code in the thanks page:

<p>
    Thanks for submitting.  We will get back to you as soon as possible.
    <p>
    <c:out value="${ticket.TicketDetails}" />
    <br>
    </div>

Upvotes: 0

Views: 651

Answers (1)

marco.eig
marco.eig

Reputation: 4239

try to an action-state:

<transition on="submit" to="addInquiry" />

<action-state id="addInquiry">
    <evaluate expression="flowActions.addInquiry(memberrequest)" result="flowScope.ticket"/>
    <transition to="endState" />
</action-state>

Upvotes: 2

Related Questions