Konfiguracja Spring Boot z Webflow oraz JSF (primefaces)

0

Cześć, tak jak w temacie próbuję skonfigurować spring boot z webflow i jsf. Jsf jako tako mi działają niestety mam problem z podpięciem webflow.
Konfiguracja webflow:

@Configuration
public class WebFlowConfiguration extends AbstractFlowConfiguration {

    private static final boolean isRichFacesPresent =
            ClassUtils.isPresent("org.richfaces.application.CoreConfiguration",
                    ResourcesBeanDefinitionParser.class.getClassLoader());

    @Bean
    public SimpleUrlHandlerMapping jsrResourceHandlerMapping() {

        Map<String, Object> urlMap = new HashMap<>();
        urlMap.put("/javax.faces.resource/**", jsfResourceRequestHandler());
        if (isRichFacesPresent) {
            urlMap.put("/rfRes/**", jsfResourceRequestHandler());
        }

        SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
        handlerMapping.setUrlMap(urlMap);
        handlerMapping.setOrder(0);
        return handlerMapping;
    }

    @Bean
    public JsfResourceRequestHandler jsfResourceRequestHandler() {
        return new JsfResourceRequestHandler();
    }

    @Bean
    public FlowDefinitionRegistry flowRegistry() {
        return getFlowDefinitionRegistryBuilder()
                .setBasePath("/")
                .addFlowLocationPattern("/**/*-flow.xml")
                .setFlowBuilderServices(this.flowBuilderServices())
                .addFlowLocation("parent-flow.xml")
                .build();
    }

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

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

}

Spring mvc:


@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private WebFlowConfiguration webFlowConfig;

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

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

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

Konfiguracja servleta faces

@SpringBootApplication
public class SpringbootwebflowApplication implements ServletContextAware {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootwebflowApplication.class, args);
    }


    @Bean
    public ServletRegistrationBean<FacesServlet> facesServletServletRegistrationBean() {
        ServletRegistrationBean<FacesServlet> servletRegistrationBean = new ServletRegistrationBean(new FacesServlet(), "*.xhtml");
        servletRegistrationBean.setLoadOnStartup(1);
        servletRegistrationBean.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        return servletRegistrationBean;
    }

    @Bean
    public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
        return new ServletListenerRegistrationBean(new ConfigureListener());
    }

    @Override
    public void setServletContext(ServletContext servletContext) {
        servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
//        servletContext.setInitParameter("javax.faces.PARTIAL_STATE_SAVING_METHOD", "true");
//        servletContext.setInitParameter("javax.faces.STATE_SAVING_METHOD", "server");
        servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
        servletContext.setInitParameter("facelets.DEVELOPMENT", "true");
        servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "1");
        servletContext.setInitParameter("facelets.DEVELOPMENT", "true");

        servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/springsecurity.taglib.xml");

        servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", Boolean.TRUE.toString());
        servletContext.setInitParameter("primefaces.CLIENT_SIDE_VALIDATION", "true");
        servletContext.setInitParameter("primefaces.THEME", "ui-lightness");
        servletContext.setInitParameter("primefaces.UPLOADER", "utils");
        servletContext.setInitParameter("primefaces.MOVE_SCRIPTS_TO_BOTTOM", "true");
    }
}

Przykładowe flow:

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/webflow
      http://www.springframework.org/schema/webflow/spring-webflow.xsd"
      parent="parent-flow">
    <var name="controller" class="com.ujazdowski.springbootwebflow.web.controller.HomePageController"/>

    <view-state id="home">
        <on-entry>
            <evaluate expression="controller.helloMessage()"/>
        </on-entry>
        <transition on="doit">
            <evaluate expression="controller.helloMessage()"/>
        </transition>
    </view-state>
</flow>

widok

<ui:composition template="../WEB-INF/layouts/standard.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">
    <ui:define name="title">Home page</ui:define>
    <ui:define name="content">
        <p:outputLabel>Dashboard</p:outputLabel>

        <p:commandButton action="doit" process="@this" value="Do it!"/>

    </ui:define>
</ui:composition>

Cały kod źródłowy umiesciłem na repozytorium SpringBootJsfWebFlowConfiguration

Walczę już z tym trzeci dzień. Proszę o pomoc

0
  1. nie napisałeś jakie są objawy, że nie działa.
  2. Wyciągnąłeś antyczne technologie :JSF i webflow. Napisz, że jeszcze portlety masz :-( . W każdym razie - koszmar.

1 użytkowników online, w tym zalogowanych: 0, gości: 1