I need to redirect to a flow from a @Controller
, but am not sure how to go about this. I need to either continue with MVC under a certain condition, or go into my flow under another condition. Here's the final line of my /auth
method:
return new ModelAndView(isFlowProtected(getClientId(sessionDataPayloadJSON)) ?
"redirect:/login-flow" :
LoginConstants.LOGIN);
Essentially, I have two login flows, one through normal Spring MVC, one under webflow. Here's how I configured my flow:
@Bean
public FlowDefinitionRegistry flowRegistry() {
return getFlowDefinitionRegistryBuilder().addFlowLocation("/webflow/login-flow.xml","login-flow"
.setFlowBuilderServices(this.flowBuilderServices())
.build();
}
@Bean
public FlowExecutor flowExecutor() {
return getFlowExecutorBuilder(this.flowRegistry())
.build();
}
@Bean
public FlowBuilderServices flowBuilderServices() {
return getFlowBuilderServicesBuilder()
.setViewFactoryCreator(this.mvcViewFactoryCreator()) // Important!
.setValidator(this.localValidatorFactoryBean).build();
}
@Bean
public FlowHandlerMapping flowHandlerMapping() {
FlowHandlerMapping handlerMapping = new FlowHandlerMapping();
handlerMapping.setOrder(-1);
handlerMapping.setFlowRegistry(this.flowRegistry());
return handlerMapping;
}
@Bean
public FlowHandlerAdapter flowHandlerAdapter() {
FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter();
handlerAdapter.setFlowExecutor(this.flowExecutor());
handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true);
return handlerAdapter;
}
@Bean
public ViewFactoryCreator mvcViewFactoryCreator() {
MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
factoryCreator.setUseSpringBeanBinding(true);
return factoryCreator;
}
Assuming my path to my flow is correct, what am I doing wrong here? How can I redirect to the login-flow
from my /auth
endpoint when needed? I'm getting the following error currently:
java.io.FileNotFoundException: Could not open ServletContext resource [/webflow/login-flow.xml]
So maybe my path is wrong? The flow is inside of resources/webflow
, so I think it's right, but maybe not?