Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic datatable binding

 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I needed to create a dynamic datatable based on some queries being executed. I did this by referring to BalusC Code link for datatables


Now my query can be modified based on some selectOneMenus. On the valueChangeListener i fire the query to to fetch the data again that populate the columns and rows. However I found that the getter method for the binding Datatable value was called only the first time the datatable is created.
Is there some way to force the binding to the datatable again? i have tried different things including moving the pagecode to request scope.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you need to make sure you call the render phase at the end of your valueChangeListener method.

Um, I forget the exact line of code, but that will re-render the table for you.

Mark
 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I tried using FacesContext.getCurrentInstance().renderResponse(), but it didn't work.
One of my colleagues then suggested obtaining the parent UIComponent and then explicitly removing that specific child. This works.

if(workerTable != null){
UIComponent abc = workerTable.getParent();
abc.getChildren().remove(workerTable);
}

Thanks
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by gov kur:
Hi,
However I found that the getter method for the binding Datatable value was called only the first time the datatable is created.
Is there some way to force the binding to the datatable again? i have tried different things including moving the pagecode to request scope.
Move the lazy loading to the getter of the data list instead of the dataTable.
 
Dumitru Andrei
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gov,

I have the same problem you encountered, my dynamic columns dataTable is not being reRendered correctly unless i reload the whole page, which is not acceptable. Can you please tell me where you placed this piece of code, in a faces listener ? My dataTable binds to a variable stored in a session scoped bean.

Thank you,
Andrei
 
Nasim Salehi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I've encountered the same problem,would you please let me know how did you exactly solve it?
I don't understand the solutions you've presented,dear gov kur what is the logic behind the way your colleagues offered?


Is workerTable the element you've bound to your datatable ?
And Bauke Scholtz,what do you mean of "Move the lazy loading to the getter of the data list instead of the dataTable."?
 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry Andrei ... in my case the whole page gets reloaded. On changing the selectOneMenus, I execute the follwoing code in the valueChangeListener of the selectOneMenus

after this the db query fires and using the fetched data i create the workerTable all over again. All this happens via function calls made in the
valueChangeListener function.
After this the whole page reloads as I have onchange="submit();" attribute in my selectOneMenu.

yes Nasim, workerTable is the element I've bound to the datatable. It's shown below

[ November 13, 2007: Message edited by: gov kur ]
 
Dylan Honorez
Ranch Hand
Posts: 30
AngularJS Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

Anyone with a decent solution for this? I've been encountering this for a while, getting servletexceptions because my page isn't entirely re-rendered. On complete re-render no errors however.

Isn't there something cleaner than manually setting your HTMLDataTable to null?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic