EDIT: I didn't get any bites on this question, so I'm adding a little more detail.
I have a Spring Webflow app (ver 2.3.2). I need to access multiple FlowScope objects from inside the validation of one of the steps (not inside the flow itself). You would think this would be simple, but I haven't been able to crack it.
Spring Webflow provides a series of special EL variables which can be used for accessing the various scopes, but only inside the flow itself. Inside a custom Spring validator, there doesn't seem to be any 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.");
}
}
}
As you can see, inside a Spring Webflow Validator there is no direct external linkage to anything except the object you are supposed to validate. I need to get to those other objects in the flowScope. Ideally either through the ApplicationContext
or some other environmental feature there must be a way to get to these other objects.
Anyone know the answer to this?
18.4 Velocity & FreeMarker Velocity and FreeMarker are two templating languages that can be used as view technologies within Spring MVC applications.
MVC is an implementation of the Model View Controller design pattern, webflow is an implementation of a "web flow" state machine. Web flow sits on top of springs MVC and allows you to define complex navigational flows.
Configuring Web Flow in Spring. Spring Web Flow is built on a foundation of Spring MVC. That means all requests to a flow first go through Spring MVC's DispatcherServlet . From there, a handful of special beans in the Spring application context must be configured to handle the flow request and execute the flow.
To enable Spring security for web flows. Explanation: You have to register the flow execution listener SecurityFlowExecutionListener in the flow executor to enable Spring Security for web flow.
You can get the scope beans from RequestContext - context holder for request-specific statecurrent web application context. Access to request context in your validator method is by:
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.RequestContextHolder;
RequestContext requestContext = RequestContextHolder.getRequestContext();
requestContext.getFlowScope().get("objectYouAreLookingFor");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With