禁用/启用 ajax 事件上的命令按钮
我希望能够在按下下面的命令按钮后将其禁用,并在事件侦听器运行并呈现 msg1 后启用它。
<h:commandButton value="Submit">
<f:ajax execute="@form" render="msg1" listener="{bean.method}" />
</h:commandButton>
我怎么能这样做呢?
更新:我发现我可以将 onclick 事件附加到 commandButton 元素本身以禁用它。如何检测侦听器方法已返回,以便我可以再次启用该按钮?
I want to be able to disable the commandbutton below once it's hit and enable it once the event listener runs and msg1 is rendered.
<h:commandButton value="Submit">
<f:ajax execute="@form" render="msg1" listener="{bean.method}" />
</h:commandButton>
How could I do this?
UPDATE: I found out that I can attach onclick event to the commandButton element itself to disable it. How can I detect the listener method has returned so I can enable the button again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以借助
的onevent
属性来完成此操作,该属性指向处理 JSF Ajax 事件的 JavaScript 函数。例如:
(请注意,我还修复了
listener
中的错误 EL)使用以下 JS:
You could do it with help of the
onevent
attribute of<f:ajax>
which points to a JavaScript function which handles the JSF Ajax events.E.g.:
(note that I fixed the wrong EL in
listener
as well)with this JS:
如果您使用 richfaces,则 a4j:commandButton 具有可防止这种情况的 status 属性。
If you use richfaces, the a4j:commandButton has the status attribute which prevent this.