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

    <secured attributes="ROLE_MEMBER" />
   
    <input name="studyId" required="true" type="java.lang.Integer" />
   
    <on-start>
        <evaluate expression="meetingService.createMeeting(studyId)" result="flowScope.meeting" />
    </on-start>
   
    <view-state id="addMeetingForm" model="meeting" view="add.jsp">
        <binder>
            <binding property="openDate" converter="shortDate" required="true" />
            <binding property="closeDate" converter="shortDate" required="true" />
            <binding property="openTime" converter="shortTime" required="true" />
            <binding property="closeTime" converter="shortTime" required="true" />
            <binding property="title" required="true" />
            <binding property="maximum" required="true" />
            <binding property="location" required="true" />
            <binding property="contents" required="true" />
        </binder>
        <transition on="proceed" to="addPresentationForm" />
        <transition on="submit" to="confrimMeetingDetail" />
        <transition on="cancel" to="cancel" bind="false" validate="false" />
    </view-state>
   
    <view-state id="addPresentationForm" model="presentation" view="presentation/add.jsp">
        <binder>
            <binding property="key" required="true" />
            <binding property="title" required="true"/>
            <binding property="topic" required="true"/>
            <binding property="summary" required="true"/>
            <binding property="presenter" converter="memberConverter"/>
        </binder>
        <on-render>
            <evaluate expression="meetingService.createPresentation(meeting)" result="viewScope.presentation"/>
        </on-render>
        <transition on="proceed" to="presentationList" history="discard">
            <evaluate expression="meetingService.addPresentation(meeting, presentation)"/>
        </transition>
        <transition on="cancel" to="cancel" bind="false" validate="false" />
    </view-state>

    <view-state id="presentationList" view="presentation/list.jsp">
        <transition on="delete" to="presentationList">
            <set name="requestScope.presentationKey" value="requestParameters.presentationKey" />
            <evaluate expression="meetingService.deletePresentation(meeting, presentationKey)" />
        </transition>
        <transition on="new" to="addPresentationForm" />
        <transition on="submit" to="confrimMeetingDetail" />
        <transition on="cancel" to="cancel" bind="false" validate="false" />
    </view-state>

    <view-state id="confrimMeetingDetail" view="confirmMeeting.jsp">
        <transition on="submit" to="submit" />
        <transition on="cancel" to="cancel" bind="false" validate="false" />
    </view-state>
   
    <end-state id="meetingEnd" view="externalRedirect:contextRelative:/study/view/${studyId}.do" />
   
    <end-state id="submit" commit="true" parent="#meetingEnd">
        <on-entry>
            <evaluate expression="meetingService.addMeeting(studyId, meeting)"/>       
        </on-entry>
    </end-state>

    <end-state id="cancel" parent="#meetingEnd" />

</flow>

일단, 이 플로우로 진입하면, addMeetingForm 뷰로 이동, 여기서 나온 transition에 따라 contirmMeetingDetail로 바로 가거나, addPresentationForm으로 이동.

addPresentationForm에서 presentationList로 이동하고, 여기서는 back할 수 없도록 history를 discard로 설정함.

대략 80 줄 정도의 XML 설정으로 아침에 구상한 플로우를 구현했습니다. 이 시나리오를 구현하는데 필요한 자바 코드는 서비스 메서드 몇 개 정도. 컨트롤러 코드는 하나도 없습니다. 만약 웹 플로우 없이, 스프링 MVC만을 이용해서 비슷한 플로우를 구현했다면 훨씬 복잡하고 코드도 길었을 텐데 다행입니다. 웹 플로우 사용법도 생각보다 간편하고 쉬웠던 것 같네요.

이제는 웹 플로우 테스트와 <persistent-context />에 대해 좀 알아봐야겠습니다.