开发者

Refresh table on render

I have a rich:extendedDataTable inside a rich:tab.

I want to refresh the table dataSource everytime that the table is rendered. It is rendered everytime that the tab is selected.

In a nut:

View:

<rich:tab>
<rich:extendedDataTable data="#{myData.data}"/>
</rich:tab>

Bean:

public class MyData{
List data;

public MyData(){
 data = this.refreshData();
}

public List getData(){
return data;
}

public List refreshData(){
//Database things here.
}
}

How can I call to refreshData everytime that the table is rendered? I can use reRender on the component that executes an action that modifies data, but that breaks encapsulation of components and its difficult to maintain. It's better if the table can refresh data by itself every time that is reRendered when the tab is activated.

I could use <rich:tab ontabenter='js_function_that_calls_the_server_and_refreshes_the_data'> but I don't think that is开发者_如何学编程 the best option, because you should place the function outside the tab tags and besides it throws two requests instead of just one.

Any ideas? appreciated.


You could try something like this:

<rich:tab action="#{mydata.refreshData}" reRender="myTable">
  <rich:extendedDataTable id="myTable" data="#{myData.data}"/>
</rich:tab>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜