单击确认按钮时,我需要刷新当前页面。我试图在互联网上找到答案,但很少或根本没有成功。如果有一种方法可以从前端(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>
你可以使用javascript
location.reload();
或者你可以重定向到与URI
相同的this answer。
首先更改commandButton来调用bean方法:
onConfirmComplete="#{messagesListBean.reload}"
在豆子里:
public void reload() throws IOException {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.redirect(((HttpServletRequest) ec.getRequest()).getRequestURI());
}
您可以使用render
的a4j:commandButton
属性来实现此目的。例:
<a4j:commandButton value="buttonName"
action="#{bean.action}"
render="someForm" />
在你的代码中将render="@none"
更改为render="@form"
或render="@all"
。