views:

69

answers:

1

I am using spring webflow 1.0. I am uploading a csv file, parsing it, and displying results before proceeding. The user has an option to download a csv file that contains the records that did not pass validation. When I click the link in a JSP to download this file, webflow invokes a form Action. The form action writes out a file via getting the output stream off the response:

HttpServletResponse response = ((ServletExternalContext) context.getExternalContext()).getResponse();

I do not want to leave the jsp I'm currently on. I just want to download the file. In other words, I do not want to transition to another state. I just want to serve the dynamically rendered file. Everything works (I don't leave the page, and I download the file), but I'm getting the following error in my console:

_pEncydKfggPHJo8=org.springframework.webflow.engine.NoMatchingTransitionException: No transition was matched on the event(s) signaled by the [1] action(s) that executed in this action state 'downloadErrorReportAction' of flow 'myFlow'; transitions must be defined to handle action result outcomes -- possible flow configuration error? Note: the eventIds signaled were: 'array<String>[[null]]', while the supported set of transitional criteria for this action state is 'array<TransitionCriteria>[[empty]]'
    at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:187)
    at org.springframework.webflow.engine.State.enter(State.java:191)
    at org.springframework.webflow.engine.Transition.execute(Transition.java:212)
    at org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
    at org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)
    Truncated. see log file for complete stacktrace

Here is the relevant portion of my webflow config.

<view-state id="showUploadResults" view="UploadResults3.0">
    <render-actions>
        <action bean="UploadResultsAction" method="transitionToWebflow"/>
        <action bean="UploadResultsAction" method="setupData"/>
    </render-actions>
    <transition on="submit" to="proceed"/>
    <transition on="downloadErrorReport" to="downloadErrorReportAction"/>
</view-state>

<action-state id="downloadErrorReportAction">
    <action bean="UploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/>
</action-state>
+1  A: 

I was able to do this by defining a view-state and specifying a render action.

<view-state id="downloadErrorReportAction">
        <render-actions>
            <action bean="uploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/>
        </render-actions>
    </view-state>

I also had to add the same transitions from the previous action, because once you click the download link, you transition to another state. So the final config looks like the following:

<view-state id="showUploadResults" view="UploadResults3.0">
   <render-actions>
      <action bean="UploadResultsAction" method="transitionToWebflow"/>
      <action bean="UploadResultsAction" method="setupData"/>
   </render-actions>
   <transition on="submit" to="proceed"/>
   <transition on="downloadErrorReport" to="downloadErrorReportAction"/>
</view-state>

<view-state id="downloadErrorReportAction">
     <render-actions>
         <action bean="uploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/>
     </render-actions>
    <transition on="submit" to="proceed"/>
</view-state>
Dave
Does anyone know of a better way to do this. This seems a little hacky.
Dave