Let's say that I have a state that looks a little something like this:
Here I have a state that could end up transitioning to one of 3 other states. But regardless of where I head off to next, I need to always invoke someService.someAction()...that's why it's in <on-exit>.Code:<view-state id="A"> <transition on="condition1" to="B" /> <transition on="condition2" to="C" /> <transition on="condition3" to="D" /> <on-exit> <evaluate expression="someService.someAction()"/> </on-exit> </view-state>
Fine...but what if someService.someAction() throws an exception? In that case I'd like to transition to "E"...so I change the state to this:
And this is where it all goes pear-shaped. As I transition away from "A", an exception is thrown from someService.someAction(). That triggers the on-exception transition...which is a transition away from "A", which means that the <on-exit> block is executed. someService.someAction() still throws an exception, which triggers the on-exception transition...which is a transition away from "A", which means...Code:<view-state id="A"> <transition on="condition1" to="B" /> <transition on="condition2" to="C" /> <transition on="condition3" to="D" /> <transition on-exception="SomeException" to "E" /> <on-exit> <evaluate expression="someService.someAction()"/> </on-exit> </view-state>
You get the picture.
I read elsewhere that it is recommended to let exceptions be handled in the service and to have the service return an event for SWF to transition from. I agree with that...but not sure that it helps me here because I'd end up with the same scenario, only without the exceptions.
Any idea how I can make this work?


Reply With Quote