Board index JavaServer Faces General Programmatic datatable refresh problem

Programmatic datatable refresh problem

Components, Ajax Framework, Utilities and More.


Posts: 4
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.
<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


Posts: 4
I tried to refresh the page by adding oncomplete as below:
<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
Location: Slovenia
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
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
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
I tried to do that as below:

<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


Posts: 5826
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.
Howard

PrimeFaces 5.0, Extensions 2.0.0, Push (Atmosphere 2.1.8)
TomEE 1.7.0 (Tomcat 7.0.55), MyFaces Core 2.2.4, JDK8
JUEL 2.2.6 | OmniFaces | EclipseLink-JPA/Derby | Chrome

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


Return to General