How to implement the select method so that the selectOne , selectTwo transitions selectOne selectTwo when the method is called?

xml:

 <action-state id="selectAction"> <evaluate expression="userSelectHandler.select()" /> <transition on="selectOne" to="one" /> <transition on="selectTwo" to="two" /> </action-state> <view-state id="one" /> <view-state id="two" /> 

Java class:

 @Component public class UserSelectHandler { public String select() { return null; } } 

    2 answers 2

    Like that

     //Π―Π²Π½ΠΎ Π·Π°Π΄Π°Π½ΠΎ имя для ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚Π° @Component("selectAction") public class UserSelectHandler { //Π€Π°Π±Ρ€ΠΈΠΊΠ° private org.springframework.webflow.action.EventFactorySupport eventFactorySupport = new org.springframework.webflow.action.EventFactorySupport(); //ΠžΠ±Ρ€Π°Ρ‚ΠΈ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹ΠΉ Ρ‚ΠΈΠΏ public org.springframework.webflow.execution.Event select() { // ΠΈΠ΄Ρ‘ΠΌ ΠΏΠΎ Ρ‚Ρ€Π°Π½Π·Π°ΠΊΡ†ΠΈΠΈ selectOne return eventFactorySupport.event(this,"selectOne"); } } 
    • Thanks a lot :) - Dmitry Sokolov

    I did something like this:

     public class Transition extends Event { public Transition(Object source, String id) { super(source, id); } public Transition(Object source, String id, AttributeMap<Object> attributes) { super(source, id, attributes); } public static Transition go(String idTransition) { RequestContext context = RequestContextHolder.getRequestContext(); Map<String, Object> contextMap = context.getFlowScope().asMap(); Map<String, Object> map = new HashMap<>(); for (Map.Entry<String, Object> entry : contextMap.entrySet()) { map.put(entry.getKey(), entry.getValue()); } Object source = context.getCurrentEvent().getSource(); AttributeMap attributeMap = new LocalAttributeMap(map); return new Transition(source, idTransition, attributeMap); } } 

    The only question that remains is how to save changes in the object, after calling the method, for example:

     <evaluate expression="userMainHandler.select(user)" />