我有类似于这样的东西:
<h:commandButton action="#{MyBean.action()}">
<f:ajax render ="@all"/>
</h:commandButton>
在ajax渲染中,是否有可能替换掉"@all"以刷新页面?
<h:commandButton action="#{MyBean.action()}">
<f:ajax render ="@all"/>
</h:commandButton>
在ajax渲染中,是否有可能替换掉"@all"以刷新页面?
使用这段代码后,我的页面就不会像按F5那样刷新了
使用ajax是无法实现这个功能的。只需删除<f:ajax>
并在操作方法中发送一个重定向到自身即可。
<h:commandButton value="Submit and refresh" action="#{bean.action}" />
public String action() {
// ...
FacesContext context = FacesContext.getCurrentInstance();
return context.getViewRoot().getViewId() + "?faces-redirect=true";
}
如果您实际上不需要执行业务操作,只需使用没有结果的<h:button>
。
<h:button value="Refresh only" />
@all
,但是我真的以为它几乎和完全重定向是一样的,好吧,可能有一些缺点,但基本内容可以刷新...(我知道在完全重定向中,视图作用域的bean将被重新创建,这是其中一个主要区别,使其与按下F5键相同) - undefined@all
,那就是像 FullAjaxExceptionHandler
一样完整显示错误页面(其在内部使用 PartialViewContext#setRenderAll()
实现)。 - undefined@all
。真幸运! - undefined