Hi all,
I'm quite new to WebFlow and the Spring Framework in general, and not very sure of my ideas yet.
When defining a view-state within a flow, you can define a view for it.
Is there also a convenient way to define model map available for this view?
What I am doing now is subclassing org.springframework.webflow.executor.mvc.FlowContr oller and overriding its toModelAndView method so it associates models and views. It looks more or less like this:
Is it a proper way of using models ?Code:public class MyFlowController extends FlowController { private MyModelClass myModel; ... protected ModelAndView toModelAndView(ResponseInstruction response, ExternalContext context) { if (response.isApplicationView()) { // forward to a view as part of an active conversation ApplicationView view = (ApplicationView)response.getViewSelection(); Map model = new HashMap(view.getModel()); <NEW CODE> String viewName = view.getViewName(); // set model for main view if(viewName.equals("main")) { model.put("modelForMain", myModel.getForMain()); } // set model for another view else if (viewName.equals("another")) { model.put("modelForAnother", myModel.getForAnother()); } // set model requiring a parameter else if (viewName.equals("viewWithParameter")) { int id = Integer.parseInt(context.getRequestParameterMap().get("id");); model.put("paramModel", myModel.getWithParameter(id)); </NEW CODE> } this.getArgumentExtractor().put(response.getFlowExecutionKey(), model); this.getArgumentExtractor().put(response.getFlowExecutionContext(), model); return new ModelAndView(view.getViewName(), model); } else { return super.toModelAndView(response, context); } }
and - Can it be done without writing any code in java?


Reply With Quote
