Page 1 of 1

Programmatic datatable refresh problem

Posted: 13 Mar 2012, 04:33
by rkundoor
Hello All,

I am createing a datatable programmatically in the backing bean when a command button is clicked and bound it in xhtml as below.

Code: Select all

<p:dataTable binding="#{ruleTableDataBean.dynamicDataTable}" id="dynamicTable"/>
<p:commandButton value="Create  Rule Table" update="dynamicTable" id="updateTableButton" actionListener="#{ruleTableDataBean.createRuleTable}"onclick="submitform()"/>
For the first time, when the "Create Rule Table" button is clicked, I checked debug mode, createRuleTable method is called in backing bean and datatable is created.
But on the screen it shows empty table. I have to manually click refresh button on the browser to display rows.

Since this table has dynamic number of columns, when I add/remove any columns in backing bean, it does not update those columns on the screen, I have to manually refresh the screen again.

But if I add/delete any rows in backing bean, it updates the table without manual refresh.

If I add/remove any columns followed by add/delete rows, button click updates both rows and columns properly without manual refresh.

I am using Prime Faces 3.0.1 with Web Sphere 8.0.

Does any one experienced similar issue ?

Thanks & Regards,
Ravi

Re: Programmatic datatable refresh problem

Posted: 15 Mar 2012, 03:10
by rkundoor
I tried to refresh the page by adding oncomplete as below:

Code: Select all

<p:commandButton value="Create  Rule Table" update="dynamicTable" id="updateTableButton" actionListener="#{ruleTableDataBean.createRuleTable}"oncomplete="window.location.reload(true)"/>
But, I have another datatable in a dialog which is displayed on the context menu item click for a selected row.
I can not refresh the page to display contents of the datatable in dialog.
When I refresh the page dialog disappears.

How to refresh programmatically created datatable without refreshing the page ?

Re: Programmatic datatable refresh problem

Posted: 20 Mar 2012, 13:38
by markok
Did you find any solution how to refresh dataTable programmatically?

I also need that, I don't wanna refresh whole page but just a dataTable.
I have one page with two layouts. In one I have dataTable in other I programmatically generate form on event: table row selected.
When I submit the form, only dataTable should be updated and not the whole page.

Re: Programmatic datatable refresh problem

Posted: 21 Mar 2012, 14:42
by rkundoor
I did not find any solution yet.

Any one has clue what could be wrong ?
Can you please advise what direction we should proceed to identify the root cause for this issue ?

Re: Programmatic datatable refresh problem

Posted: 21 Mar 2012, 15:22
by MTornros
It's really hard to know without seeing code for the entire page (or a simplified version of the page where the error still exists). Most likely is that the attribute update="dynamicTable" can not find any element to update. You should try using the full id of the datatable, you can find the full id with "inspect element" in chrome or similar in other browsers.

Re: Programmatic datatable refresh problem

Posted: 21 Mar 2012, 21:14
by rkundoor
I tried to do that as below:

Code: Select all

<p:dataTable binding="#{ruleTableDataBean.dynamicDataTable}" id="dynamicTable"/>
<p:commandButton value="Create  Rule Table" update=":tableForm:dynamicTablePanel,:tableForm:dynamicTable" id="updateTableButton" actionListener="#{ruleTableDataBean.createRuleTable}"onclick="submitform()"/>
But still it did not refresh the table.

I will try to use "inspect element" as you suggested and find out what is the correct id for datatable. And also I will post the simplified version of the page and bean code.

Thanks
-Ravi

Re: Programmatic datatable refresh problem

Posted: 21 Mar 2012, 21:50
by smithh032772
1. In your p:dataTable, replace binding="..." with value="..."
2. Replace your programmatically-rendered dataTable xhtml and bean logic with the following:

a. dataTable dynamic columns showcase sample
b. h:panelGroup rendered="..." around your p:dataTable, if you need to conditionally render entire table

I may have misunderstood you, but I think you just want to programmatically-render (or develop) dataTable with 'dynamic columns', and you want to always render the dataTable with dynamic columns.

I was reading a related topic/post on stackoverflow.com a few minutes ago, but it was for h:dataTable instead of PrimeFaces p:dataTable.