View Full Version : Can the flow respond to a middleware callback?
Feb 11th, 2008, 04:45 AM
Is it possible to have the flow respond to a middleware callback?
I have the case where on one page, the user starts a lengthy data extraction process. They are then taken to a 'data extracting' page.
Is it possible to have the flow automatically move on to a new view-state when the extraction complete callback returns?
I've thought of two possible solutions: Firstly have some sort of looping action state (containing a pause) that keeps transitioning to itself until the process is complete. This would work, but given that the extraction can take several hours, I need an exit option (button), so the user can go away and come back later, which I don't think would be possible in this set up.
The second is to access the flow executor from the middleware, and signal an event when the callback comes. I'm not keen on this option, as I'm still pretty new to webflow, and everything I read about accessing the executor from outside makes it sound v hard to implement. And I'm not even sure if you can signal events or not.
Is there another way of doing this? Has anyone done anything similar? Or, if I have to go for option 2, any reccomendations? I've read the tip1 on ervacon, but don't fully understand it.
Many thanks in advance.
Feb 12th, 2008, 07:59 AM
Why don't you have your middleware process update a database table with a completion time/date and just query that?
Feb 12th, 2008, 08:08 AM
It's because I want it to forward automatically. I'd have the same problem trying to get the flow to query the table.
Doing it on a user button click is not a problem. Getting it to do it whilst on a view state (i.e. the flow is paused), without a user input is causing me grief.
I've gone for option 2, and am most of the way to implementing it now, except for one significant part. My thread class which runs the extraction needs access to the FlowExecutor to be able to use resume.
I tried just injecting the Executor (as a bean) straight in, but this doesn't work, I'm guessing it's something to do with the way webflow beans are created. Is there any way I can get hold of the flowExecutor in an Action and pass it to my thread?
I thought I'd solved it this morning, but realised I was confusing ExecutorImpl and ExecutionImpl - again! D'oh!
Feb 13th, 2008, 04:42 AM
After singularly failing to get hold of the flow executor, I've gone for the flowExecution, and tried
When I debug, the flowExecution has moved state correctly, and now thinks it is in the new state (where I want it to be). However, the web page view does not change. Refreshing the browser does nothing either.
I'm pulling my hair out over this, surely I can't be the only person who's tried to do this. Does anyone know of something I can do to get the view to correspond to my updated FlowExecution?
Feb 14th, 2008, 05:42 AM
This has the page visibly reloading every 5s, which I really don't like. If anyone has a suggestion of how to just manipulate the flow from within, I'd really apprecate it. If this isn't possible, would it be worth considering for an addition?
Feb 14th, 2008, 09:58 AM
It's possible to have actions embedded in the transition element. If the action completes successfully, the transition completes. So if you were to access the middleware from such a transition, would that take care of the issue?
I was also scanning through this:
Which describes accessing flow execution state asynchronously. So hypothetically I would think that that the page could make an xhr request to DWR, which could kick off the middleware request, and then once that returns, the flow could be found and the right transition executed. Wish I could be more specific. Still in the process of testing various scenarios out.
Feb 15th, 2008, 02:42 AM
With embedded actions in transitions, if the action returns an event the flow doesn't know how to deal with, you get a flowException of some kind.
I've solved the problem (sort of). I use dwr access the middleware, and check to see if the process has finished, and then submit my hidden form if it has. It side steps the flow, but it does the required job, with no ugly page refreshes, so I'm happy.
Thanks for your advice!
Feb 15th, 2008, 09:40 AM
Sounds terrific. Just something to keep in mind for the future...As I was reading I also noticed that the there are on-exception transitions as well that could be used to deal with exceptions thrown in the middleware calling step. So you would have to catch them and throw the exception that maps to the view containing the error message.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.