如何使用Spring Webflow popup ="true"用Primefaces? [英] How to use Spring Webflow popup="true" with Primefaces?

查看:98
本文介绍了如何使用Spring Webflow popup ="true"用Primefaces?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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弃用了Spring.js,并使用以下语句删除了标记库:

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

Spring Web Flow的早期版本附带一个组件库,该组件库为JSF 1.2环境提供了Ajax和客户端验证功能.使用这些组件的应用程序将需要切换到第三方JSF组件库,例如PrimeFaces或RichFaces.

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

现在,我在pom.xml中添加了对Primefaces 5.2的依赖关系,除了SWF Popups之外,其他一切似乎都可以正常工作,SWF Popups可以直接重定向到新的视图状态.

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.

第一页:

<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 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,因为没有什么特别之处.

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

使用Mojarra 2.2,Primefaces 5.2,Spring 4.2和Webflow 2.4.1.

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

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

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>

如果有人设法在这些版本上(不管有没有Spring.js)都可以使用popup ="true",那么我将很高兴听到它.

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

推荐答案

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

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

这并不能真正回答我的问题,但是无论popup设置为true还是false,Webflow都会发送相同的响应,对此我看不到任何答案.

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.

这篇关于如何使用Spring Webflow popup ="true"用Primefaces?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆