Spring-boot: Spring Web Flow starter

Created on 16 Mar 2014  路  19Comments  路  Source: spring-projects/spring-boot

Create a starter for SWF to be able to easily integrate SWF configs into Boot apps. Not sure what it would look like, but creating an issue so it could be considered.

declined

Most helpful comment

Would really love if this could be reconsidered. Web Flow is a very good solution to a problem that is still relevant today, it would be great to have an official starter for it.

All 19 comments

Thanks for the idea. Someone could try it and see. If it ends up just being starter-web + webflow there isn't much value. Webflow isn't really all that fashionable these days so I'm not sure we want to have a starter devoted to it, but we can debate that here if you like.

No debate necessary, but for example SFW is at the core of CAS server (which is our "bread and butter" software) which enables us to make all the different customizations to the login flows, etc.

https://github.com/Jasig/cas

And I was just thinking of writing a next generation of CAS server with Boot, but still utilize SWF. That's where the idea for this issue came in :-)

Best,
Dmitriy.

I think on balance there isn't the audience for a dedicated Web Flow starter so I'm closing this one for now.

Thanks for the suggestion, if we get a lot of comments on this issue we can reconsider.

I am also planning to make a Boot application using Web Flow, therefore I also think a webflow-starter would be nice.
Alternatively/additionally, it would be nice to have some posts/tutorials/example where both Boot and Web Flow are present

Too bad GH Issues doesn't have a vote button :-)

But other than that - love the GH Issues. Smart move. Would be terrific if Spring XD folks came to their senses and also moved to GitHub Issues ;-)

@dima767 In the CAS case wouldn't you have to build a "template" server that the user customizes anyway? So you can probably add the SWF dependencies to that - the user will have to include it as a dependency anyway so they might as well just do that and not have to bother including SWF explicitly as well.

@ghiottolino if anyone wants to propose a Getting Started guide for SWF they can do it by creating a github project and tweeting the URL to @springcentral.

Dave, currently CAS publishes a "template" war to Maven central repo with all its core modules as well as SWF central authentication flow config. Then the pattern for customization is that folks create their local CAS maven project which depend on that centrally published CAS war and employ a mechanism called Maven war overlay to introduce SWF and any other customizations to build the final, customized war that they deployed.

The idea of using Boot for the next gen CAS server sounds too exciting and I was just exploring the possible ways to do this with Spring Boot, make it flexible and customizable and at the same time retain the use of SWF. So this issue was the "avenue" to brainstorm on the possible ways to do that :-)

I think you can just publish a JAR with transitive dependencies to SWF and users can depend on it - it's a lot simpler to operate (and safer) than a war overlay. If you try it and something is awkward we can definitely try and help out at that point.

Old thread. I know, I know. But just for the record. Here's what currently requires at minimum for config to get the Boot going with SWF and Thymeleaf:

@Configuration
public class WebFlowConfig extends AbstractFlowConfiguration {

    @Autowired
    private WebMvcConfig webMvcConfig;

    @Autowired
    private List<ViewResolver> viewResolvers;

    @Bean
    public FlowExecutor flowExecutor() {
        return getFlowExecutorBuilder(flowRegistry())
                .addFlowExecutionListener(new SecurityFlowExecutionListener(), "*")
                .build();
    }

    @Bean
    public FlowDefinitionRegistry flowRegistry() {
        return getFlowDefinitionRegistryBuilder(flowBuilderServices())
                .setBasePath("classpath*:/templates")
                .addFlowLocationPattern("/**/*-flow.xml")
                .build();
    }

    @Bean
    public FlowBuilderServices flowBuilderServices() {
        return getFlowBuilderServicesBuilder()
                .setViewFactoryCreator(mvcViewFactoryCreator())
                .build();
    }

    @Bean
    public MvcViewFactoryCreator mvcViewFactoryCreator() {
        viewResolvers.add(this.webMvcConfig.ajaxThymeleafViewResolver());

        MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
        factoryCreator.setViewResolvers(viewResolvers);
        factoryCreator.setUseSpringBeanBinding(true);
        return factoryCreator;
    }

}
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private WebFlowConfig webFlowConfig;

    @Autowired
    private SpringTemplateEngine springTemplateEngine;

    @Bean
    public FlowHandlerMapping flowHandlerMapping() {
        FlowHandlerMapping handlerMapping = new FlowHandlerMapping();
        handlerMapping.setOrder(-1);
        handlerMapping.setFlowRegistry(this.webFlowConfig.flowRegistry());
        return handlerMapping;
    }

    @Bean
    public FlowHandlerAdapter flowHandlerAdapter() {
        FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter();
        handlerAdapter.setFlowExecutor(this.webFlowConfig.flowExecutor());
        handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true);
        return handlerAdapter;
    }

    @Bean
    public AjaxThymeleafViewResolver ajaxThymeleafViewResolver() {
        AjaxThymeleafViewResolver viewResolver = new AjaxThymeleafViewResolver();
        viewResolver.setViewClass(FlowAjaxThymeleafView.class);
        viewResolver.setTemplateEngine(springTemplateEngine);
        return viewResolver;
    }
}

As one could imagine this boilerplate will be needed in every Boot/SWF/Thymeleaf project. So perhaps a starter which will contribute an autoconfigure for this minimum set of beans or may be an explicit @EnableSpringWebFlow.

Just a food for thought.

Cheers,
D.

+1 for adding the starter. Web Flow may be out of fashion, but it looks like it's exactly the tool I need for handling some workflow wizards, and Spring Session just made the keep-partial-transactions-in-session-state model workable again. The configuration above, cleaned up a tad a Bootified, would be very helpful as a starter config. I'd be up for building a starter if there was a likelihood it'd be added.

@chrylis Go for it. What's the worst that could happen? If it doesn't get included in Boot's core, this could always be packaged and released as a sep. dependency, etc.

/cc @rstoyanchev who might be interested in the Spring Session comment.

@dima767 There's a lot of subtlety regarding view and resource resolvers that I don't understand. (For example, using relative view paths Just Doesn't Work, and while I've read the code and see why it doesn't work, I don't understand why the code if written that way.) I have a configuration that works-for-me, but something suitable for general consumption would need specific review.

Just fyi,

Spring Roo 2.0.0.M3 generates Spring Boot applications and integrates Spring Web Flow easier than ever.

The reference guide includes detailed descriptions of all the features.

Glad to see this feature.

Would really love if this could be reconsidered. Web Flow is a very good solution to a problem that is still relevant today, it would be great to have an official starter for it.

Please reopen it if possible.

now?

Although Spring Web Flow still serves a purpose and is being maintained, we don't feel like it's a good candidate to have support out of the box in Spring Boot. We're mainly seeing developers opt for richer Javascript frameworks when they need flow style applications, and we'd rather encourage that direction.

Sorry to everyone that's tracking the issue, but we have no plans to add Spring Web Flow support.

Was this page helpful?
0 / 5 - 0 ratings