开发者

reRender a specific row of rich:dataTable

开发者 https://www.devze.com 2023-03-31 16:05 出处:网络
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

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开发者_StackOverflow.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:

  • 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 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 );
0

精彩评论

暂无评论...
验证码 换一张
取 消