17

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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
WheelPot
  • 307
  • 1
  • 3
  • 15

2 Answers2

26

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());
}
Community
  • 1
  • 1
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
2

You can use render attribute of a4j:commandButton for this purpose. Example:

<a4j:commandButton value="buttonName"
    action="#{bean.action}"
    render="someForm" />

In your code change render="@none" to render="@form" or render="@all".

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40