Programmatic datatable refresh problem

Components, Ajax Framework, Utilities and More.
Post Reply
Posts: 4
Joined: 13 Mar 2012, 03:02

13 Mar 2012, 04:33

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,

Posts: 4
Joined: 13 Mar 2012, 03:02

15 Mar 2012, 03:10

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 ?

Posts: 2
Joined: 16 Nov 2011, 13:07
Location: Slovenia

20 Mar 2012, 13:38

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.

Posts: 4
Joined: 13 Mar 2012, 03:02

21 Mar 2012, 14:42

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 ?

Posts: 102
Joined: 23 Dec 2011, 16:43

21 Mar 2012, 15:22

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.
Primefaces 3.4.1-jQueryfix
Spring webflow 2.3.1
Mojarra jsf 2.1.7

Posts: 4
Joined: 13 Mar 2012, 03:02

21 Mar 2012, 21:14

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.


Posts: 6144
Joined: 10 Sep 2011, 21:10

21 Mar 2012, 21:50

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 a few minutes ago, but it was for h:dataTable instead of PrimeFaces p:dataTable.

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider], Google [Bot] and 25 guests