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 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());
}