1

I am trying to add webflow to a spring boot app using joinfaces library.

I am using primefaces-spring-boot-starter and jetty-spring-boot-starter to configure jetty server.

Added necessary webflow dependencies to pom and configured necessary flowregistry, flowbuilderservices, flowexecutor and flowhandlermapping, ...

The application start correctly, reads the flows definitions from xmls and if enter to a flow via url the decision states are running correctly, reads the corresponding view state .xhtml file, calls the managed bean methods, and all are working apparently well.

But... once finished executing bean methods, when I hope to html be rendered in browser, the application is redirected to app root folder without any error in the log.

I have this behavior with all the flows of the application. Bean methods are executed correctly and when I hope to see the html... redirected to root.

Anyone tried to add webflow to a joinfaces jsf application successfully? I am missing to override some default configuration of joinfaces?

Thanks.

public class MvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private WebFlowConfiguration webFlowConfiguration;

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

    @Bean
    public FlowHandlerAdapter flowHandlerAdapter() {
        JsfFlowHandlerAdapter adapter = new JsfFlowHandlerAdapter();
        adapter.setFlowExecutor(this.webFlowConfiguration.flowExecutor());
        return adapter;
    }

    @Bean
    public ViewResolver faceletsViewResolver() {
        UrlBasedViewResolver resolver = new UrlBasedViewResolver();
        resolver.setViewClass(JsfView.class);
        resolver.setPrefix("/");
        resolver.setSuffix(".xhtml");
        return resolver;
    }
}

@Configuration
public class WebFlowConfiguration extends AbstractFacesFlowConfiguration {

    @Bean
    public FlowDefinitionRegistry flowRegistry() {
        return getFlowDefinitionRegistryBuilder()
                .setBasePath("classpath*:/META-INF/resources/flows")
                .addFlowLocationPattern("/**/*.xml")
                .setFlowBuilderServices(flowBuilderServices())
                .build();
    }

    @Bean
    public FlowBuilderServices flowBuilderServices() {
        return getFlowBuilderServicesBuilder()
                .setDevelopmentMode(true)
                .setViewFactoryCreator(new JsfViewFactoryCreator())
                .build();
    }

    @Bean
    public FlowExecutor flowExecutor() {
        return getFlowExecutorBuilder(flowRegistry())
                .addFlowExecutionListener(new FlowFacesContextLifecycleListener())
                .addFlowExecutionListener(new SecurityFlowExecutionListener())
                .setMaxFlowExecutionSnapshots(0)
                .build();
    }

}
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Ozius
  • 11
  • 2
  • Why webflow and not the jsf 'flow' for things? Webflow is good for spring-mvc, not JSF. And the problem is 100% (ok 99%) not PrimeFaces related. – Kukeltje Oct 16 '18 at 12:07
  • We are migrating an old spring 3 + jsf + webflow app to spring boot. Replace webflow for another technology is not posible. The problem is not primefaces related, maybe joinfaces configuration problem? – Ozius Oct 16 '18 at 17:00
  • No idea, don't do spring in any way. All java-ee for me. – Kukeltje Oct 16 '18 at 18:03
  • Can you provide an MCVE project? – larsgrefer Oct 16 '18 at 23:18
  • Created a simple project and uploaded to github https://github.com/Ozius/aura-commons-web http://localhost:8080/auracommons/ is the url to enter app, the index has two links, one to a jsf file that shows correctly and other to the webflow defined. Resolves the flow correctly, executes the bean methods but redirects to root. – Ozius Oct 17 '18 at 08:41

0 Answers0