【问题标题】:How to use Spring Webflow popup="true" with Primefaces?如何在 Primefaces 中使用 Spring Webflow popup="true"?
【发布时间】:2015-09-11 11:51:10
【问题描述】:

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

Webflow 2.4 弃用了 Spring.js 并使用以下语句删除了 taglib:

Spring Web Flow 的先前版本附带了一个组件库,该组件库为 JSF 1.2 环境提供了 Ajax 和客户端验证功能。使用这些组件的应用程序需要切换到第三方 JSF 组件库,例如 PrimeFaces 或 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>

弹簧配置:

<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,我都会很高兴听到。

【问题讨论】:

  • 仅供参考:从 2.2 版开始,JSF 通过 CDI @FlowScoped 注释提供了新的内置流范围,从而使 SWF 变得多余。
  • 我们尝试了 Faces Flows,但在使用自定义 JSF 实现并附带 MyFaces 2.0(修改版)时,WebSphere 似乎不支持 CDI。

标签: spring jsf primefaces jsf-2.2 spring-webflow-2


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2011-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 2011-09-16
    • 2012-04-07
    • 1970-01-01
    相关资源
    最近更新 更多