<?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-1.0.xsd">

  <start-state idref="view"/>

  <view-state id="view" view="blog.EntryView">
    <render-actions>
      <action bean="blog.entryViewAction" method="setupForm"/>
    </render-actions>
    <transition on="submit" to="anonymousOrNot">
      <action bean="blog.entryViewAction" method="bindAndValidate"/>
      <action bean="blog.entryViewAction" method="isAnonymous"/>
    </transition>
  </view-state>

  <decision-state id="anonymousOrNot">
    <if test="${flowScope.isAnonymous}" then="captcha" else="post"/>
  </decision-state>

  <subflow-state flow="captcha-sub-flow" id="captcha">
    <transition on="finish" to="post"/>
  </subflow-state>

  <action-state id="post">
    <action bean="blog.entryViewAction" method="postComment"/>
    <transition on="success" to="finish"/>
  </action-state>

  <end-state id="finish" view="externalRedirect:/blog/${flowScope.blog.code}/entry-${flowScope.entry.code}.html#comment${flowScope.comment.id}"/>

</flow>
