aspose file tools*
The moose likes JSF and the fly likes dynamic datatable binding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "dynamic datatable binding" Watch "dynamic datatable binding" New topic
Author

dynamic datatable binding

gov kur
Ranch Hand

Joined: Aug 30, 2004
Posts: 73
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

Joined: Feb 05, 2001
Posts: 17257
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
gov kur
Ranch Hand

Joined: Aug 30, 2004
Posts: 73
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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Oct 25, 2007
Posts: 1
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

Joined: Oct 23, 2007
Posts: 9
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

Joined: Aug 30, 2004
Posts: 73
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
Greenhorn

Joined: Oct 02, 2006
Posts: 29
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?


SCJP - SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic datatable binding