How to use Spring Webflow popup=“true” with Primefaces?

纵饮孤独 提交于 2019-12-11 10:45:36

问题


Until now we were using Spring Webflow 2.3, which brought the "sf" namespace and Spring.js, which could be used to display view-states in a popup.

Webflow 2.4 deprecated Spring.js and removed the taglib with the following statement:

Previous releases of Spring Web Flow shipped with a component library which provided Ajax and client-side validation capabilities for JSF 1.2 environments. Applications using these components will need to switch to a 3rd party JSF component library such as PrimeFaces or RichFaces.

See: http://docs.spring.io/spring-webflow/docs/current/reference/htmlsingle/#spring-faces-upgrade-from-swf23-components

Now i have added a dependency to Primefaces 5.2 to my pom.xml and everything seems to work fine, except for SWF Popups, which simply redirect to the new view-state.

First page:

<ui:composition template="#{templatePath}"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <h:form id="formDashboard">

            <p:commandButton id="addWidget" value="Hinzufügen" action="add-widget"/>

        </h:form>
    </ui:define>

</ui:composition>

Second page (should be rendered in a popup):

<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

    <ui:fragment id="popupFragment">
        abc
    </ui:fragment>

</ui:composition>

Flow definition:

<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">

    <view-state id="start" view="dashboard.xhtml">
        <transition on="add-widget" to="popup-addWidget"/>
    </view-state>

    <view-state id="popup-addWidget" view="popup-addWidget.xhtml" popup="true">
        <on-render>
            <render fragments="popupFragment"/>
        </on-render>
    </view-state>

</flow>

Spring configuration:

<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
    <property name="flowExecutor" ref="flowExecutor"/>
</bean>

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry"/>
</bean>

<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    <webflow:flow-execution-listeners>
        <webflow:listener ref="facesContextListener"/>
    </webflow:flow-execution-listeners>
</webflow:flow-executor>

<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"/>

<!-- Populates the flowRegistry on startup. Removing this and manually adding all flows changes nothing.  -->
<bean class="config.FlowRegisteringBeanPostProcessor"/>

<faces:flow-builder-services id="flowBuilderServices"/>

<faces:resources/>

<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>

I'm not including the web.xml, since there is nothing special.

Using Mojarra 2.2, Primefaces 5.2, Spring 4.2 and Webflow 2.4.1.

Using Firebug i can see that the server POST response issues to redirect, which JSF/Primefaces honors and does a full redirect to the new view-state instead of showing a popup:

<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1"><redirect url="/Demo/spr/dashboard?execution=e1s2"></redirect></partial-response>

If anybody managed to get popup="true" working with these versions, with or without Spring.js, i'd be happy to hear about it.


回答1:


We ended up using Primefaces' p:dialog and p:confirmDialog, instead of Webflow popups.

This doesn't really answer my question, but i can't see an answer to this seeing that Webflow sends the same response no matter if popup is set to true or false.



来源:https://stackoverflow.com/questions/32522858/how-to-use-spring-webflow-popup-true-with-primefaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!