title: Transition to parameterized webflow view state from global menu
body: <h1>Background</h1>
  
  <p>Simple menu system with links that should display specific report parameter pages. Here's how it works:</p>
  
  <ol>
  <li>The user clicks the "Search" menu, switching to the System Search web flow.</li>
  <li>The user clicks a "Reports" sub-menu (e.g., "Errors Encountered...").</li>
  <li>The user is taken to the Errors Encountered report.</li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/CIDrN.png" alt="Menu"></p>
  
  <p>The <code>reports-flow.xml</code> contains:</p>
  
  <pre><code>&lt;view-state id="list" view="flow/reports/list"&gt;
      &lt;transition on="parameters" to="parameters"&gt;
          &lt;set name="flowScope.reportKey" value="requestParameters.key" /&gt;
          &lt;evaluate expression="reportService.createReport()" result="flowScope.report" /&gt;
      &lt;/transition&gt;
  &lt;/view-state&gt;
  
  &lt;view-state id="parameters" model="report" view="flow/reports/parameters"&gt;
      &lt;on-render&gt;
          &lt;set name="viewScope.pageId" value="'osre02'" /&gt;
          &lt;evaluate expression="siteService.find()" result="viewScope.siteList" /&gt;
          &lt;evaluate expression="agencyService.findActiveMunicipalities()" result="viewScope.municipalityList" /&gt;
      &lt;/on-render&gt;
  
      &lt;transition on="run" to="redirect" /&gt;
  &lt;/view-state&gt;
  </code></pre>
  
  <p>The <code>flow/reports/list</code> page contains:</p>
  
  <pre><code>&lt;li&gt;&lt;a href="${flowExecutionUrl}&amp;amp;_eventId=parameters&amp;amp;key=report_name"&gt;Report Name&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <h1>Problem</h1>
  
  <p>None of the following work to exit the system search web flow and enter the report web flow while passing the report parameter key.</p>
  
  <pre><code>&lt;a href="reports?_flowId=reports&amp;_eventId=parameters&amp;key=report_name"&gt;Report Name&lt;/a&gt;
  &lt;a href="reports?_eventId=parameters&amp;key=report_name"&gt;Report Name&lt;/a&gt;
  &lt;a href="reports?execution=${flowExecutionKey}&amp;amp;_eventId=parameters&amp;key=report_name"&gt;Report Name&lt;/a&gt;
  &lt;a href="${flowExecutionUrl}&amp;amp;_eventId=parameters&amp;key=report_name"&gt;Report Name&lt;/a&gt;
  </code></pre>
  
  <h1>Error</h1>
  
  <p>From the System Search web flow, the following error appears:</p>
  
  <blockquote>
    <p>Request processing failed; nested exception is org.springframework.webflow.engine.NoMatchingTransitionException: No transition found on occurence of event 'parameters' in state 'criteria' of flow 'flow/sessionSearch' -- valid transitional criteria are array[search, today] ...etc.</p>
  </blockquote>
  
  <p>This error goes away when clicking one of the menu links while already in the report flow. This makes sense because the System Search doesn't know about the reports flow nor the menu (ideally, it shouldn't).</p>
  
  <h1>Idea</h1>
  
  <p>To make the reports flow resolve as a global menu, a global-transition can be set up as follows:</p>
  
  <pre><code>&lt;global-transitions&gt;
      &lt;transition on="parameters" to="parameters"&gt;
          &lt;set name="flowScope.reportKey" value="requestParameters.key" /&gt;
          &lt;evaluate expression="reportService.createReport()" result="flowScope.report" /&gt;
      &lt;/transition&gt;
  &lt;/global-transitions&gt;
  </code></pre>
  
  <p>And the file configuration autowired using:</p>
  
  <pre><code>@Configuration
  public class SharedWebFlowConfig extends AbstractFlowConfiguration {
      @Bean
      public FlowDefinitionRegistry sharedFlowRegistry() {
          return getFlowDefinitionRegistryBuilder().addFlowLocation("/WEB-INF/flow/common/global-transitions.xml", "global-transitions").build();
      }
  }
  </code></pre>
  
  <h1>Question</h1>
  
  <p>The set-up described in the idea section results in the following error:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Cannot find state with id 'parameters' in flow 'flow/sessionSearch' -- Known state ids ...</p>
  </blockquote>
  
  <p>How do you make the <code>parameters</code> view-state from the <code>reports-flow.xml</code> global?</p>
  
  <p>What would be a better approach?</p>