views:

18

answers:

1

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.

+1  A: 

You could try something like this:

<rich:tab action="#{mydata.refreshData}" reRender="myTable">
  <rich:extendedDataTable id="myTable" data="#{myData.data}"/>
</rich:tab>
amorfis
omg, I didn't realize that `tab` has the `action` parameter. That makes things so much easier...Thanks, I'm gonna try.
pakore
Check here: http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/rich/tab.html
amorfis
Yep, I always use that documentation. I don't know why but I didn't pay attention on the action parameter at first. It works now, thanks.
pakore