On the surface, a bit of a strange question! but I am creating a web app that uses both webflow and traditional Spring MVC controllers.
From one of the webflow views, a http request (ajax) is made from the client to a spring controller. When this was originally coded it didnt have much of a logical connection to the webflow, but now things have moved on and the controller could really do with knowing what screen (view-state) the request has come from.
My controller method signature looks like this:
@RequestMapping(value="/AjaxStuff", method=RequestMethod.POST)
public String ajaxStuff(@ModelAttribute("quote") QB2MotorQuote p_quote, BindingResult p_bindingResult,
HttpServletRequest p_req, Model p_model, DefaultMessageContext p_messages) {
I know from some of my webflow action classes that I can get the current state from the RequestContext object:
public Event checkDeclines(RequestContext p_ctx) throws Exception {
// get the current state
StateDefinition state = p_ctx.getCurrentState();
I've never really understood the 'voodoo' :) that Spring does where it can automagically inject parameters just by specifying them on the method signature (surely it can only inject things it knows about ??). I've tried simply changing the method signature of my controller method to inject in the RequestContext (in the vain hope that it will get injected), but it doesn't. It complains that RequestContext is an interface.
So, does anyone know how I can make my controller know about the current webflow state - either through injecting something into the controller method signature, or perhaps I can get it from the http request somehow (or session, which I can get from the request).
Any help with this very much appreciated.
inside your webflow view, you should have access to a variable ${flowRequestContext}
that you can use in your ajax call.
you can just get the piece of information ${flowRequestContext.currentState}
you want from it and add it as a parameter.
you cannot have the requestContext directly injected as your are not in a webflow environment. If you were, you could directly use RequestContext.getRequestContext()
. Try calling it from your MVC controller and you will get null. Try from within a flow and you will get it.
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