I've the following view-state
:
<view-state id="editbestellung" view="eap/orderedit.xhtml"
model="flowScope.entity">
<transition on="save" to="eaporderlist" bind="true">
<evaluate
expression="eapBestellungDelegate.save(flowScope.entity,currentUser.name)" />
</transition>
</view-state>
No elsewhere I set a flowScope.isToDo
on true.
Now I need to check if this flowScope is true. If it is, the transition
should redirect to="eapordertodolist"
and if it is false, it should go to="eaporderlist"
.
But I only know how to set the if-statement like that:
<if test="testingMethod()" then="view-state when true" else="view-state when false" />
So how can I implement the if-statement inside of the view-state above and do the needed actions?
Use Decision-States
Use the decision-state element as an alternative to the action-state to make a routing decision using a convenient if/else syntax. The example below shows the moreAnswersNeeded state above now implemented as a decision state instead of an action-state
Your editbestellung
-state will look like this (notice that i changed the to
):
<view-state id="editbestellung" view="eap/orderedit.xhtml"
model="flowScope.entity">
<transition on="save" to="eaporderdecision" bind="true">
<evaluate
expression="eapBestellungDelegate.save(flowScope.entity,currentUser.name)" />
</transition>
</view-state>
Then you add the decision-state:
<decision-state id="eaporderdecision">
<if test="flowScope.isToDo" then="eapordertodolist" else="eaporderlist" />
</decision-state>