如何在 Primefaces 中使用 Spring Webflow popup="true"?

How to use Spring Webflow popup="true" with Primefaces?

到目前为止,我们一直在使用 Spring Webflow 2.3,它带来了 "sf" 命名空间和 Spring.js,可用于在弹出窗口中显示视图状态。

Webflow 2.4 已弃用 Spring.js 并使用以下语句删除了标签库:

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.

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

现在我已将 Primefaces 5.2 的依赖项添加到我的 pom.xml 并且一切似乎都工作正常,除了 SWF 弹出窗口,它只是重定向到新的视图状态。

第一页:

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

第二页(应在弹出窗口中呈现):

<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 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配置:

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

我不包括 web.xml,因为没有什么特别的。

使用 Mojarra 2.2、Primefaces 5.2、Spring 4.2 和 Webflow 2.4.1。

使用 Firebug 我可以看到服务器 POST 响应问题重定向,JSF/Primefaces 尊重并完全重定向到新的视图状态而不是显示弹出窗口:

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

如果有人设法让 popup="true" 使用这些版本,有或没有 Spring.js,我很乐意听到它。

我们最终使用了 Primefaces 的 p:dialog 和 p:confirmDialog,而不是 Webflow 弹出窗口。

这并没有真正回答我的问题,但我看不到这个问题的答案,因为无论弹出窗口设置为真还是假,Webflow 都会发送相同的响应。