datatable/component not updated after deleting and adding new one

datatable/component not updated after deleting and adding new one

During working on tabular data, it is common to have edit and delete command buttons for each row.

And, after we update or delete we want the table to be updated. Let’s looks some simple example.

The table on the JSF might look like

<form id="tablularForm">
<h:datatable id="tabularData" value="#{someBean.list}"
binding="#{someBean.htmlDataTable}" var="data">
<h:outputText id="colum1" value="#{data.column}" />
<h:CommandLink id="edit" value="Edit" action="#{someBean.editAction}" reRender="tabularData"/>
<h:CommandLink id="delete" value="Delete" action="#{someBean.deleteAction}" reRender="tabularData"/>
<h:CommandButton id="add" value="add" action="#{someBean.addAction}" />

The above ideal table would work fine.

The datatable would store values by reading from bean and would be updated on Edit and Delete actions accordingly.

This is b/c of the reRender attribute of the components.

The glitch comes when there is no any data in the table. Say you daleted all the data and you want to add a new one.

Or it is the brand new table to be added.

The row would be added but it wont be shown on the table. In short the table would not be updated.

The thing is when we use reRender, we have to use the enclosing component not the component to be safe!.

When it tries to rerender if the component was not there initially, it wont rerender it.
So, here we can use the id of the form for rerendering the datatable and we would be OK.

See why jsf apps are slow in cases

See how you would solve these known algorithm problems

Check if there are three numbers a, b, c giving a total T from array A

Find the pairs that makes K Complementary in the given array java solution

Find the first occurence of number in the sorted array

testing k complementary pairs algorithm with junit

Check if two strings are anagrams or not

Changing decimal number to its binary equivalent

Java solution for checking anagram strings – tell if phrases are anagrams

Find K Complementary numbers from array Java implementation

String Ordered Permutation Algorithm Problem

binary tree problems with solution

Leave a Reply

Your email address will not be published. Required fields are marked *