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

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

问题描述

我有一个数据表。该表的每一行有一个的commandButton 所谓的删除的,这是应该从模型和视图中删除该行并执行更新到位。作为一个页脚,我还有一个的commandButton 所谓的删除所有行的。

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 包含的元素为空)和的dataTable 页脚面是重新呈现在视图(或更新)。

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 页脚面并没有改变。

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.

我有下面这段code在我的 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

推荐答案

我认识到这个问题,是我们当前的功率因数3.0的网页之一。如果你使用更新=@表相反,它会正常工作。我还没有真正有研究的真正原因,这样我可以报告给PF的家伙,因为这个问题不清单中的所有页面的时间。即使在同一个表,不同的按钮的工作原理intented。

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


更新:来想一想,它可能关系到过程中的presence =@这个


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

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

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