hello,
I am - unfortunally - working with jsf and I am experiencing a problem.
I have a jsf page that displays a table with some data, using the <h:dataTable>
component.
Every row of this table has an <h:commandLink>
with a Remove action to remove the item in that row.
When I perform that action, the method in the backing bean is correctly called, the ArrayList that contains the table items is correctly uptaded, and the navigation method to come back in the same page where the table is, is correctly performed.
But when the page is reloaded the table is not updated. I see the same items that were in the table before the remove action.
If I reload again the page, now the table is updated.
It seems just like the view is rendered before that the backing bean has completed its updates.
How can I force to render the view just when the backing bean has completed its updates?
Here some code:
The commandLink in the jsf page, inside the dataTable:
<h:column>
<f:facet name="header">
<h:outputText value="Rimuovi" />
</f:facet>
<h:commandLink action="#{servicesListBean.removeServizio}" title="Rimuovi questo servizio" onclick="if(!confirm('Vuoi davvero rimuovere questo servizio?')) return false">
<h:outputText value="Rimuovi" />
</h:commandLink>
</h:column>
And here the method in the backing bean:
public String removeServizio() {
this.servizioToRemove = (Servizio) getDataTable().getRowData();
try {
ServiziDAO.removeServizio(this.servizioToRemove.getId());
} catch (Exception e) {
// ...
}
return userSessionBean.goToElencoServizi();
}
In this case, I gave request scope to the backing bean. I already tried to give it session scope and call a method to update the list, but the result is the same.
I hope I was clear enough. Thanks to everyone in advance.
UPDATE TO THIS QUESTION THAT CHANGES EVERYTHING
Thanks to everyone. As McDowell said, the problem was not in the time when view was rendered, and the problem was not JSF related at all.
What happened is that when I removed an item from the DB, I did not delete the row, I just set an end date to the item. This is the right way to do it in my application, but while in the query that setted the end date to the item I took the time using System.currentTimiMillis()
, in the query that reloaded the uptaded list I used the sysdate
of the Oracle server.
There are some fractions of second of difference between this two dates, and that's why I could see the updated list just when I reloaded the page: because one ore two second were passed!
Maybe this issue can be useful to someone else.