在h:commandButton上放置指标(如a4j:status)

时间:2011-03-31 10:56:50

标签: java jsf richfaces

我们正在使用Richfaces 3.3.3.Final。我们的问题是关于 a4j:commandButton 导航问题。如果我们使用a4j:commandButton(请访问:http://community.jboss.org/wiki/CommonAjaxRequestsProblems#navigation),我知道导航无法正常工作。

好的,我知道我必须使用 h:commandButton 才能正常导航。但现在我需要一个可与h:commandButton一起使用的指标组件。 <a4j:status>不适用于h:commandButton。

有什么建议吗?

感谢。

1 个答案:

答案 0 :(得分:2)

<h:commandButton不能与a4j:status一起使用,因为它不会触发任何ajax请求 - 它会触发常规请求。使用ajax浏览浏览器是没有意义的。

您似乎希望在导航时显示正在进行的工作。这在http中通常是不可能的 - 您要么请求新页面并等待它来,要么发出ajax请求。

但你可以做另一件事 - 使用<a4j:commandButton oncomplete="redirectBrowser();">,其中redirectBrowser()是一个改变当前网址的javascript函数:window.href.location=/desired/target.jsf'。当ajax响应返回时,它将被触发。此外,您可以禁用按钮onclick,这样用户就不会再点击两次。