I need to refresh current page when confirm button is clicked. I am trying to find the answer on the internet, but with little or no success at all. It would be nice if there was a way to update it from front-end (JSF), not from backing bean, but, I will take both answers as solutions.
My command button looks like this:
<a4j:commandButton id="deleteButton" styleClass="simpleButtonRed"
value="#{msg['common.delete']}"
execute="@this" render="@none" limitRender="true" >
<adn:confirm
id="confirmButtonas"
message="#{msg['common.delete.confirm']}"
confirmAction="#{messagesListBean.deleteMessages}"
confirmLabel="#{msg['common.confirm']}"
confirmBtnStyleClass="mainButtonGreen"
confirmImmediate="true"
confirmRender="errorMessageOuterPanel"
onConfirmComplete="if(#{!messagesListBean.operationCompleted}) {
#{rich:component('errorPanel')}.show();}"/>
</a4j:commandButton>
You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.
The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.
You can use javascript
location.reload();
Or you can redirect to same URI
as in this answer.
First change commandButton to call bean method:
onConfirmComplete="#{messagesListBean.reload}"
And in the bean:
public void reload() throws IOException {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.redirect(((HttpServletRequest) ec.getRequest()).getRequestURI());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With