I have a page that displays orders, each order has a status of "Read/Unread". When you click the order id, you are redirected to a new page to visualize the PDF order. From the PDF file, you have a back button that takes you back to the page with the table of orders, and there the status of the order you just visualized has to be changed from "Unread" to "Read".
The issue: if you click the "back" button immediately after reaching the PDF visualization, the status of the order is not updated because the DOM is not updated so fast. Only after you refresh manually the page you can see the changed status.
I was thinking to add a delay on the back button until DOM is updated. (tried to reload the page automatically but doesn't look good).
The only problem is that I can't delay the button. I tried using the setTimeout directly in the onComplete, also tried to define a function in <script></script>
and call it with setTimeout..not sure why is not working.
Here is my code:
<g:documentViewer value="#{cc.attrs.value.viewer}" rendered="#{cc.attrs.value.viewer!=null}">
<f:facet name="actions">
<p:commandButton id="backbtn"
value="#{'back'}"
immediate="false"
process="@this"
update="@(.docPnl)"
styleClass="#{'btn btn-primary'}"
oncomplete="setTimeout(9000000); updateColumns(true); resetOrderBy();">
<f:setPropertyActionListener target="#{cc.attrs.value.viewer}" value="#{null}"/>
</p:commandButton>
</g:documentViewer>