views:

969

answers:

2

I have a rich dataTable that's defined inside of an a4j:outputPanel, and that's bound to a session-scoped backing bean that creates the HtmlDataTable. By itself, that part of my code is working fine, and the dataTable looks good.

On another part of the page, there are some basic text links that I'm creating as a4j:commandLinks, and when those are clicked, the dataTable should be re-rendered with new row and column data. The row data's updating fine, but the column data (header text, width, etc.) isn't.

After digging around the code for a bit, it seems that the call to the backing bean for the HtmlDataTable isn't being made during the reRendering of that table, but it is reRendered if the whole page is reloaded; so it seems that it's just the ajax4jsf/reRendering portion that's biting me here.

Is there any way that I can force the reRender process to invalidate the dataTable structure so that it will call the backing bean again for it?

If it means anything, I'm also using Seam; so if there's a solution to be found using it, that'd be helpful, too.

Thanks!

A: 

In your action just remove the session scoped bean from your contexts.

For example:

<a:commandLink action="#{someBean.perform}" value="Submit" reRender="myTable"/>

and the action:

@Name("someBean")
public class SomeBean {

  public void perform() {
    //do stuff

    Contexts.removeFromAllContexts("myBean");  
  }
}

Othewrwise if your dataTable is populated with a list then it's probably as easy as just calling the search() or whatever method loads the data.

Damo
Thanks for the suggestion, Damo, but after that change, I'm still seeing the problem. Your example is the correct setup general setup: My "someBean" class handles the commandLink click, and the "myBean" class holds the reference to the table. Removing "myBean" from all contexts still shows me original dataTable structure, even though the columns have changed in the backing bean.
Robert Seely
A: 

For posterity's sake, I've found the solution: Whenever the a4j request is made to my action listener bean, I have it tell the dataTable-building bean to flush its table. That bean then does a simple myDataTable.getParent().getChildren().remove(myDataTable). This page helped me figure it out: http://www.coderanch.com/t/213312/JSF/java/dynamic-datatable-binding.

Robert Seely