ajax调用成功后数据表不更新 [英] Datatable does not update after successful ajax call

查看:25
本文介绍了ajax调用成功后数据表不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据表.表的每一行都有一个名为 'Remove'commandButton,它应该从模型和视图中删除该行并就地执行更新.作为页脚,我有另一个 commandButton 叫做 'Remove every row'.

I have a data table. Each row of the table has a commandButton called 'Remove', which is supposed to remove that row from the model and the view and perform an update in-place. As a footer, I have another commandButton called 'Remove every row'.

最后一个按钮有效.我点击它,每一行都从模型中删除(即包含元素的 ArrayList 变为空)并且 dataTablefooter facet 是在视图中重新渲染(或更新).

The last button works. I click on it, every row is removed from the model (i.e the ArrayList containing the elements becomes empty) and the dataTable and footer facet is re-rendered (or updated) in the view.

另一方面,当我单击其中一行上的按钮将其删除时,它部分工作.相应的元素从模型中删除,但视图没有更新.该行仍然存在于 dataTable 中,并且 footer facet 没有改变.

On the other hand, when I click a button on one of the rows, to remove it, it partially works. The corresponding element is removed from the model but the view is not updated. That row is still there in the dataTable and the footer facet hasn't changed.

我的 users.xhtml 中有以下代码.

I have the following piece of code in my users.xhtml.

<f:metadata>
    <f:viewParam name="id" value="#{users.id}" />
    <f:event type="preRenderView" listener="#{users.init}" />
</f:metadata>

...

<h:form id="usersForm">
    <p:outputPanel>    
        <p:dataTable id="userTable" value="#{users.user.friendList}" var="friend">
            <p:column>
                <h:outputText value="#{friend.name}" />
            </p:column>
            <p:column>
                <p:commandButton action="#{users.user.removeFriend(friend)}"
                    ajax="true"
                    update="userTable somethingElse" process="@this"
                    onerror="errorDialog.show();"
                    icon="ui-icon-delete"
                    title="delete user">
                </p:commandButton>
            </p:column>

            <f:facet id="somethingElse" name="footer">  
                    aye: ${users.user.xxx}
            </f:facet>
        </p:dataTable>

    </p:outputPanel>

    <p:commandButton action="#{users.user.removeAllFriends()}" ajax="true"
                update="userTable somethingElse"
                process="@this"
                icon="ui-icon-close"
                value="delete all friends?">
    </p:commandButton>


</h:form>

那么,您认为这里的问题是什么?

So, what do you think is the problem here?

我使用的是 JSF 2.0 和 Primefaces 3.0

I'm using JSF 2.0 and Primefaces 3.0

推荐答案

我从我们当前的 PF 3.0 页面中发现了这个问题.如果您改用 update="@form" 它将起作用.我真的没有时间去调查真正的原因,以便我可以将其报告给 PF 人员,因为此问题并非在所有页面中都出现.即使在同一个表格中,不同的按钮也会按预期工作.

I recognize this problem form one of our current PF 3.0 pages. It will work if you use update="@form" instead. I haven't really had the time to investigate the real cause so that I can report it to the PF guys, because this problem does not manifest in all pages. Even in the same table, a different button works as intented.

试试看:

<p:commandButton update="@form" ... />

<小时>

更新:仔细想想,可能和process="@this"的存在有关.


Update: coming to think about it, it's maybe related to the presence of process="@this".

这篇关于ajax调用成功后数据表不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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