Good Morning!
Is it possible to reRender only 1 specific row of rich:dataTable?
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
}
THANK YOU VERY MUCH.
Yes , it is possible . You have to specify the followings things:
reRender
attribute of the tags that can invoke MBean methodajaxKeys
attribute of the rich:dataTable
.The ajaxKeys
attribute is bound to Set <Integer>
Object which holds the row numbers to be updated.
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>
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 );