相关疑难解决方法(0)

成功调用ajax后,Datatable不会更新

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

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

另一方面,当我单击其中一行上的按钮时,为了将其删除,它会部分起作用.从模型中删除相应的元素,但不更新视图.那行还在那里,dataTablefooter facet没有改变.

我的代码中有以下代码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?"> …
Run Code Online (Sandbox Code Playgroud)

ajax jsf primefaces jsf-2

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

ajax ×1

jsf ×1

jsf-2 ×1

primefaces ×1