How can I access Spring Webflow FlowScope elements outside of a stream?

EDIT: I had no bites on this, so I am adding a little more detail.

I have a Spring Webflow application (version 2.3.2). I need to access several FlowScope objects from checking one of the steps (not inside the stream itself). You would think that it would be easy, but I could not crack it.

Spring Webflow provides a series of special EL variables that can be used to access different areas, but only within the stream itself. Inside the custom Spring validator, there seems to be no way to get to them:

@Component
public class MyObjectValidator {

    @Autowired
    ApplicationContext context;

    public void validateMyObject(MyObject myObject, Errors errors) {

        FlowScope flowScope = context.someMagicFunction();  //  <---- UNKNOWN  
        MyOtherObject otherObject = flowScope.get("otherObject");  

        if (incrediblyComplexValidation(myObject, otherObject) {
            errors.rejectValue("myField","validation.fail","Your object failed validation.");
        }
    }
}

, Spring Webflow Validator -, , , flowScope. ApplicationContext, - .

- ?

+4
1

beans RequestContext - - . :

    import org.springframework.webflow.execution.RequestContext;
    import org.springframework.webflow.execution.RequestContextHolder;

    RequestContext requestContext = RequestContextHolder.getRequestContext();
    requestContext.getFlowScope().get("objectYouAreLookingFor");
+12

Source: https://habr.com/ru/post/1532186/


All Articles