primefaces订单清单未随更改的订单更新 [英] primefaces orderlist not getting updated with the changed order

查看:51
本文介绍了primefaces订单清单未随更改的订单更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个素数p:orderList,单击按钮后会在弹出窗口中显示.当我更改订单列表中项目的顺序,然后单击弹出窗口上的保存订单按钮时,我看不到更改后的订单列表. PFB我的代码-

I have a primefaces p:orderList which is displayed in a popup on click of a button. When I change the order of Items in the orderlist, and click on Save Order button on the popup, I'm not seeing the list with the changed order. PFB my code -

<p:commandButton ajax="true" id="toolOrderButton" value="Tool Order" onclick="toolOrderPopup.show()" type="button"/>
<p:dialog header="Tool Order" severity="alert" widgetVar="toolOrderPopup"
                        appendToBody="true">  
    <p:orderList id="toolOrderList" controlsLocation="right" value="#{toolBean.toolOrderList}" var="tool" itemLabel="#{tool}" itemValue="#{tool}" iconOnly="true"/>
    <p:commandButton ajax="true"  value="Save Order" process="@this" type="submit" actionListener="#{toolBean.setToolOrder}" oncomplete="toolOrderPopup.hide()"/>
    <p:commandButton value="Cancel" onclick="toolOrderPopup.hide()" type="button"/>   
</p:dialog>

在bean中:

public void setToolOrder(){ 
    System.out.println("toolOrderList-" + BeanStringConverter.convertToString(toolOrderList));
}

请让我知道代码可能有什么问题.

Please let me know what could be wrong with the code.

推荐答案

您需要处理p:orderlist来保存orderList模型:

You need to process the p:orderlist to get the orderList model saved:

<p:commandButton ajax="true" value="Save Order" 
                 process="@this toolOrderList"
                 actionListener="#{toolBean.setToolOrder}"
                 oncomplete="toolOrderPopup.hide()"/>

与您的问题无关,您可能会遇到类似这样的情况:

Unrelated to your question you probably have something like:

<h:form>
    ...
    <p:commandButton ajax="true" id="toolOrderButton" value="Tool Order" onclick="toolOrderPopup.show()" type="button"/>
    ...
    <p:dialog header="Tool Order" severity="alert" widgetVar="toolOrderPopup"
                    appendToBody="true">  
        <p:orderList id="toolOrderList" controlsLocation="right" value="#{toolBean.toolOrderList}" var="tool" itemLabel="#{tool}" itemValue="#{tool}" iconOnly="true"/>
        <p:commandButton ajax="true" value="Save Order" 
                         process="@this" 
                         actionListener="#{toolBean.setToolOrder}" 
                         oncomplete="toolOrderPopup.hide()"/>
        <p:commandButton value="Cancel" 
                         onclick="toolOrderPopup.hide()" type="button"/>   
    </p:dialog>
</h:form>

如果是这样,那么请参阅Primefaces文档对appentToBody的评价:

if so, then see what primefaces doc says about appentToBody:

请谨慎使用appendToBody,因为页面定义和html dom会有所不同,因为 在浏览器上对话框是否位于h:form组件内且启用了appendToBody的示例 对话框将超出窗体范围,并可能导致意外结果.在这种情况下,请在其中嵌套一个表单 一个对话框.

Use appendToBody with care as the page definition and html dom would be different, for example if dialog is inside an h:form component and appendToBody is enabled, on the browser dialog would be outside of form and may cause unexpected results. In this case, nest a form inside a dialog.

以下是一种替代结构:

    <h:form id="first">
        ...
        <p:commandButton ajax="true" id="toolOrderButton" value="Tool Order" onclick="toolOrderPopup.show()" type="button"/>
        ...
    </h:form>
    <p:dialog header="Tool Order" severity="alert" widgetVar="toolOrderPopup"
                    appendToBody="true">
        <h:form id="second">
            <p:orderList id="toolOrderList" controlsLocation="right" value="#{toolBean.toolOrderList}" var="tool" itemLabel="#{tool}" itemValue="#{tool}" iconOnly="true"/>
            <p:commandButton ajax="true"  value="Save Order"
                             process="@this toolOrderList" 
                             actionListener="#{toolBean.setToolOrder}" oncomplete="toolOrderPopup.hide()"/>
            <p:commandButton value="Cancel" onclick="toolOrderPopup.hide()" type="button"/>
        </h:form> 
    </p:dialog>
</h:form>

这篇关于primefaces订单清单未随更改的订单更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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