如何在单击按钮时重新加载页面?

Whe*_*Pot 10 jsf richfaces reload

单击确认按钮时,我需要刷新当前页面.我试图在互联网上找到答案,但很少或根本没有成功.如果有一种方法可以从前端(JSF)而不是从支持bean更新它,那将是很好的,但是,我将把这两个答案作为解决方案.

我的命令按钮如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)

Jor*_*lla 16

你可以使用javascript

location.reload();
Run Code Online (Sandbox Code Playgroud)

或者,你可以重定向到同URI这个答案.

首先更改commandButton来调用bean方法:

onConfirmComplete="#{messagesListBean.reload}"
Run Code Online (Sandbox Code Playgroud)

在豆子里:

public void reload() throws IOException {
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    ec.redirect(((HttpServletRequest) ec.getRequest()).getRequestURI());
}
Run Code Online (Sandbox Code Playgroud)