重新渲染rich:dataTable的特定行 [英] reRender a specific row of rich:dataTable
问题描述
早上好!
是否可以仅重新渲染rich:dataTable的1个特定行?
我有一个rich:dataTable,当我确定只有1行发生更改时,我只需要重新行此行,而不是整个表.是否有可能?怎么样?
I have a rich:dataTable and, when I do something that I´m sure only 1 row has changed, I need to reRednder only this row, not the entire table. Is it possible? How?
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
}
非常感谢.
推荐答案
是的,有可能.您必须指定以下内容:
Yes , it is possible . You have to specify the followings things:
- 哪些列将通过可以调用MBean方法的标记的
reRender
属性呈现 - 要通过
rich:dataTable
的ajaxKeys
属性呈现哪些行.
- Which columns to be rendered via the
reRender
attribute of the tags that can invoke MBean method - What rows to be rendered via the
ajaxKeys
attribute of therich:dataTable
.
ajaxKeys
属性绑定到Set <Integer>
对象,该对象保存要更新的行号.
The ajaxKeys
attribute is bound to Set <Integer>
Object which holds the row numbers to be updated.
例如,假设您要使用a4j:commandButton
调用Mbean方法,并希望在操作完成后呈现特定的行和列.您可以使用以下内容:
For example , suppose you want to invoke a Mbean method using a4j:commandButton
and want to render a particular row and column after the action finishes . You can use the following :
<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
整数集:
Inside the bean.someAction()
, you add the row number that you want to update to the rowsToUpdate
integer set:
HashSet<Integer> rows = new HashSet<Integer>();
rows.add(selectedRow);
setRowsToUpdate( rows );
这篇关于重新渲染rich:dataTable的特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!