user1069528
user1069528

Reputation: 618

In Spring Webflow how do I transition from a failed on-start evaluate

I'm new to Spring Webflow and I'm trying to modify an existing flow to check user authorization for using the flow based on several rules. There doesn't seem to be an obvious (widely documented) method of transitioning from an evaluation to some kind of end condition. Transitions I understand are not allowed in on-start. Other than throwing an exception is there a graceful way to transition? Thanks.

Here is a form is created for edit. I added the authorization checking code to the referenced method. I could add a separate evaluate before that to check the authorization but I still have the transition problem.

<on-start>
    <evaluate        expression="solutionCreateEditFlowHelper.findDocumentForEdit(requestParameters.solutionId)" result="flowScope.documentForm"></evaluate>

>

Upvotes: 2

Views: 5633

Answers (1)

rptmat57
rptmat57

Reputation: 3787

you don't always need <on-start>. you can have a decision state as starting state, and check inside that decision state if your condition is true or false, if true then transition to your view-state or other state, if not transition to a end state with a view.

let's say you call your flow documentFlow.xml
inside this file, you put a decision-state like the following:

<input name="solutionId" type="long" />

<decision-state id="isDocumentFormSet">
<on-entry>
    <evaluate expression="solutionCreateEditFlowHelper.findDocumentForEdit(solutionId)" result="flowScope.documentForm"/>
</on-entry>
    <if test="documentForm == null" then="chooseDocument" else="noDocument"/>
</decision-state>

<end-state id="noDocument"/>

<view-state id="chooseDocument">
....
</view-state>

Upvotes: 5

Related Questions