本文介绍了数据表不与JSF Ajax调用渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

予有需要在使用时的每一行中发现一个Ajax命令被刷新的数据表。

I have a data table that needs to be refreshed upon using an ajax command found in each row.

<div class="authorSection">
    <h:dataTable id="author-table" var="author" value="#{authorPOCBean.getauthors()}">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Org Short Name" />
            </f:facet>
            <h:outputText id="authorOrganizationShortName" value="#author.orgShortName}" />
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Organization Name" />
            </f:facet>
            <h:outputText id="authorOrganizationName" value="#{author.orgName}" />
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Location" />
            </f:facet>
            <h:outputText id="authorLocation" value="#{author.orgLocation}" />
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="author Type" />
            </f:facet>
            <h:outputText id="authorType" value="#{author.authorName}" />
        </h:column>
        <h:column>
            <h:form id="deleteauthorForm">
                <h:commandLink action="#{authorPOCBean.deleteauthor(author)}" value="Delete">
                    <f:ajax render=":author-table"/>
                </h:commandLink>
            </h:form>
            <h:form id="setInitialauthorForm">
                <h:commandLink action="#{authorPOCBean.makeInitialauthor(author)}" value="Make Initial"/>
            </h:form>
        </h:column>
    </h:dataTable>
</div>

在删除功能时,似乎离开餐桌不变或者用旧的数据呈现呢?我想起来了设置的第一件事就是被调用的方法确实是改变内部数组然后更改数据库的东西,但它仍然使用旧数据。

When the delete function is used it seems to leave the table unchanged or perhaps renders it with old data? I've got it set now to the first thing the called method does is change the internal array THEN changes the database stuff but it still uses the old data.

有什么明显的毛病我code?

Is there something obviously wrong with my code?

我已经看过下面的链接,并试图提出的建议,并没有新的结果。事实上,如果我周围的表形式的表将无法建立正确的。

I have looked at the below link and tried the recommendations and have no new result. In fact if I surround the table with a form the table won't build right.

JSF-&LT; F:AJAX&GT;无法呈现的数据表

推荐答案

请注意,放置了删除按钮,并封装在一个单独的表格最初的按钮,而数据表组件放置在窗体之外。

Please be noted that you have placed the Delete Button and Make initial Buttons enclosed in a separate form whereas the DataTable component is placed outside the form .

尝试有开始在餐桌上开始的单一形式。 (IE)您的表组件和两个按钮应在同一表单内封闭

Try having a single form starting at at the start of the table . (ie) Your table component and the two buttons should be enclosed within the same form

和Ajaxical刷新,下面应该为你工作。

and for Ajaxical refresh, the following should work for you .

   <f:ajax render="@form"/>

如果由于某种其他原因不能使用一个单一的形式,需要多种形式,请参考这个问题的

If for some other reason you cannot use a single form and need multiple forms , Please refer this question How to retain form data in a multi form page

这篇关于数据表不与JSF Ajax调用渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:24