spring-webflow
spring-webflow copied to clipboard
Add support for immediately executing a transition after rendering a view within a view state (e.g. for rendering a JasperReport in the middle of a flow) [SWF-423]
Colin Yates opened SWF-423 and commented
It is really hard to render Jasper Report views from within a flow. The problem is that no event is ever submitted from the PDF, therefore the flow pauses indefinitely.
Using continuations is a workaround, but that isn't really a good answer.
An elegant solution to this (I think) is to have eventless transitions, so I could do something like this:
<some-state id="displaySearchResults"> <...> <transition on="print" to="renderPdf"/> </some-state> <view-state id="renderPdf" view="thePdfView"> <transition to="displaySearchResults"/> </view-state>
So when the renderPdf view-state is executed the flow immediately transitions back to displaySearchResults. Alternatively, maybe here should be a special type of transition, which doesn't progress the flow.
Another approach is to define all the PDF views using SpringMVC and then use FacesContextUtils (cannot remember the name) to each in and pull out the info from the flow, but that is pretty hard to swallow :)
Affects: 2.0 M3
Issue Links:
- #1251 Introduce view state "event handlers": transitions with no target state that respond to intra-page events (typically via Ajax).
2 votes, 2 watchers
Dave Syer commented
I think there is quite a large market for this kind of thing - report generation is just one example. We could go even further and build some framework features that support asynchronous requests more generically. The client wants this report. Doesn't relly care how long it takes, but wants to be notified (ideally by it popping up in a window) when it is ready. The HTML view that he was looking at when he asked to generate the report shouldn't go away - in fact it should be able to show the status of the asynchronous request (and allow him to cancel it. OK, so does this sound familiar? I'm sure I've heard you guys talking about stuff like this already - is it in the "flow component" category?
Keith Donald commented
What do you mean "maybe here should be a special type of transition which doesn't progress te flow"? We are considering adding support for transitions without target states (see #1251), so you could render your Jasper report as part of event handling without changing the state of the flow. In your example, this would be done in your "displaySearchResults" state. Is this what you mean?
BTW: your approach suggesting you get a hold of the FacesContext outside of a SWF request isn't possible since M2. I'm not sure I would call it an approach :-)
Colin Yates commented
Maybe I misunderstand #1251, but I don't see how this will render a view, since the view is a view-state, not an action.
When I render a report, I really do want to transition to a new state, a view-state, I then immediately want to transition back to another state (probably the state I was called from).
I guess I am struggling to see how the event-less transition based XML will look for this usecase. can you provide an example?