【问题标题】:reRender a specific row of rich:dataTable重新渲染rich:dataTable的特定行
【发布时间】:2011-11-05 20:17:09
【问题描述】:

早安!

是否可以只重新渲染rich:dataTable 的 1 个特定行?

我有一个 rich:dataTable,当我做一些我确定只有 1 行发生变化的事情时,我只需要重新渲染这一行,而不是整个表。可能吗?怎么样?

XHTML:

<rich:dataTable id="myTable"  value="#{bean.table}" var="me">
    <rich:column>
        <h:outputText value="#{me.id}" />
    </rich:column>
    <rich:column>
        <h:outputText value="#{me.valueOne}" />
    </rich:column>
    <rich:column>
        <h:outputText value="#{me.valueTwo}" />
    </rich:column>
</rich:dataTable>

<some:tag.... reRender="??????" action="bean.example" />

Java:
public void example{
   // Do something that affects to the row selected
}

非常感谢。

【问题讨论】:

    标签: xhtml richfaces row richdatatable rerender


    【解决方案1】:

    是的,这是可能的。您必须指定以下内容:

    • 通过可以调用MBean方法的标签的reRender属性来渲染哪些列
    • 通过rich:dataTableajaxKeys 属性呈现哪些行。

    ajaxKeys 属性绑定到 Set &lt;Integer&gt; 对象,该对象包含要更新的行号。

    例如,假设您想使用 a4j:commandButton 调用 Mbean 方法,并希望在操作完成后呈现特定的行和列。您可以使用以下内容:

    <a4j:commandButton action="#{bean.someAction}"  reRender="columnID,columnID2">
        <f:setPropertyActionListener value="#{idx}" target="#{bean.selectedRow}" />
    </a4j:commandButton>
    
     <rich:dataTable id="myTable"  value="#{bean.table}" var="me" ajaxKeys="#{bean.rowsToUpdate}" rowKeyVar="idx">
            <rich:column id="columnID">
                <h:outputText value="#{me.id}" />
            </rich:column>
            <rich:column id="columnID2">
                <h:outputText value="#{me.valueOne}" />
            </rich:column>
            <rich:column>
                <h:outputText value="#{me.valueTwo}" />
            </rich:column>
        </rich:dataTable>
    

    bean.someAction() 中,将要更新的行号添加到 rowsToUpdate 整数集:

    HashSet<Integer> rows = new HashSet<Integer>();
    rows.add(selectedRow);
    setRowsToUpdate( rows );
    

    【讨论】:

    • Ken Chan,它有效!非常感谢!!!!只有一件事:我必须使用 dataTable 中的 rowKeyVar 属性来知道选择了哪一行:) --> 再次感谢。
    • 你好。我只想执行一行,只向服务器发送一行的信息而不是所有表?
    猜你喜欢
    • 2011-08-28
    • 2013-06-26
    • 2011-04-20
    • 1970-01-01
    • 2020-12-30
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    相关资源
    最近更新 更多